57 users online (0 members and 57 guests)  


  Results 1 to 6 of 6

Related

  1. form input changes textarea output    Forum: Javascript Forum
    Replies: 1
  2. Replies: 6
  3. Replies: 1
  4. Help W/ interactive user input form    Forum: Javascript Forum
    Replies: 1
  5. CGI form input doesn't write to text file    Forum: CGI Perl Forum
    Replies: 2
  1. #1
    GregD493's Avatar
    New User

    Status
    Offline
    Join Date
    Jan 2004
    Posts
    4

    trying to write to textarea based on user input

    hello,

    I am trying to write to multiple textarea boxes

    we have multiple banners and would like to include the link code in a textarea box below each banner.

    each affiliate has a unique code that is in the middle of the link.

    there is an input at the top of the page that asks for the users affiliate code. untill they enter the code the textarea shows xxxxx in place of the numbers.

    everything works fine for the first banner, but the second doesnt update with the affiliate code.

    any suggestions?

    here is the function and form:

    Code:
    <head>
    <SCRIPT LANGUAGE=javascript>
    <!--
    function GenerateLink(){
    
    	document.getElementById("textarea1").value="<A href='http://refer.website.com/cgi-bin/clicks.cgi?id=" + document.getElementById("affiliateId").value +"&HTML=home.html'><IMG src='http://www.website.com/banners/banner1.gif' height=60 width=468 border=0></A>";
    	document.textarea1.style="display:block";
    
            document.getElementById("textarea2").value="<A href='http://refer.website.com/cgi-bin/clicks.cgi?id=" + document.getElementById("affiliateId").value +"&HTML=home.html'><IMG src='http://www.website.com/banners/banner2.gif' height=60 width=468 border=0></A>";
    	document.textarea2.style="display:block";
    }
    //-->
    </SCRIPT>
    </head>
    <body>
    
    <pre>
    <form name=userform>
    Affiliatel ID:  <input type=text name="affiliateId" size=8 value="" >
    <Br>
    <input type=button name=action value="Submit" onClick="GenerateLink()">
    </form>
    </pre>
    <p>
    <img src="http://www.website.com/banners/banner1.gif">
    <textarea NAME="textarea" ROWS=5 COLS=50 WRAP=VIRTUAL id=textarea1>
    &lt;a href=&quot;http://refer.website.com/cgi-bin/clicks.cgi?id=XXXXXX&HTML=home.html&quot;&gt;&lt;img src=&quot;http://www.website.com/banners/banner1.gif&quot; width=468 height=60 border=0&gt;&lt;/a&gt;
    </textarea>
    
    <img src="http://www.website.com/banners/banner2.gif">
    <textarea NAME="textarea" ROWS=5 COLS=50 WRAP=VIRTUAL id=textarea1>
    &lt;a href=&quot;http://refer.website.com/cgi-bin/clicks.cgi?id=XXXXXX&HTML=home.html&quot;&gt;&lt;img src=&quot;http://www.website.com/banners/banner2.gif&quot; width=468 height=60 border=0&gt;&lt;/a&gt;
    </textarea>
    
    </body>
    Last edited by HTML; 01-05-2004 at 09:13 PM.

  2. #2
    GregD493's Avatar
    New User

    Status
    Offline
    Join Date
    Jan 2004
    Posts
    4

    error in what is shown...

    above the second textarea id is shown as id=textarea1 (which is the same as the first)

    it should be textarea2... i just got frustrated and started trying different things to see if anything changed. but even as textarea2 the problems the same.

  3. #3
    Enigma's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Nov 2000
    Posts
    426
    First of all, your textareas should be within the <FORM> tags.

  4. #4
    GregD493's Avatar
    New User

    Status
    Offline
    Join Date
    Jan 2004
    Posts
    4

    No luck

    I wouldnt think that the form tag would matter since the textareas are being used for output not input. But I'm no expert so I moved the tag down and closed the form after both textareas and gave it another try with no luck.

  5. #5
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    enigma is correct.
    Try this simplified version -

    Code:
    <head>
    <SCRIPT LANGUAGE="javascript">
    <!--
    function GenerateLink(formObj){
    
    formObj.link1.value="<A href='http://refer.website.com/cgi-bin/clicks.cgi?id=" + formObj.affiliateId.value +"&HTML=home.html'><IMG src='http://www.website.com/banners/banner1.gif' height=60 width=468 border=0></A>";
    
    
    formObj.link2.value="<A href='http://refer.website.com/cgi-bin/clicks.cgi?id=" + formObj.affiliateId.value +"&HTML=home.html'><IMG src='http://www.website.com/banners/banner2.gif' height=60 width=468 border=0></A>";
    
    }
    //-->
    </SCRIPT>
    </head>
    <body>
    
    <pre>
    <form name="userform">
    Affiliatel ID: <input type=text name="affiliateId" size=8 value="" >
    <Br>
    <input type=button name=action value="Submit" onClick="GenerateLink(this.form);">
    
    </pre>
    <p>
    <img src="http://www.website.com/banners/banner1.gif">
    <textarea NAME="link1" ROWS=5 COLS=50 WRAP=VIRTUAL id="link1">
    </textarea>
    
    <img src="http://www.website.com/banners/banner2.gif">
    <textarea NAME="link2" ROWS=5 COLS=50 WRAP=VIRTUAL id="link2">
    </textarea>
    </form>
    </body>
    works fine, so you shouldbe able to build the rest of your functionality around that.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  6. #6
    GregD493's Avatar
    New User

    Status
    Offline
    Join Date
    Jan 2004
    Posts
    4

    That was it!

    Thanks, everythings working great now...

    difinately appreciate your help!

    Greg



Tags for this Thread