Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Aug 2003
    Location
    scotland, edinburgh
    Posts
    176
    Thanks
    5
    Thanked 1 Time in 1 Post

    copy text from one area to another

    Is there a way of copying text from one textarea to another via a list box
    eg
    1. Have a textarea where somone has written text in
    2. Then an option to put the same text above into a textarea below
    3. So that if yes is selected the same text in now in textarea 2

    is something like that possible?
    thanks

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Posts
    1,404
    Thanks
    2
    Thanked 32 Times in 32 Posts
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" 
        "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    <head>
    <title>untitled</title>
    </head>
    <body>
    <form>
    <h3>Textarea 1</h3>
    <textarea name="TA1"></textarea>
    <p>
    <strong>Transfer text from <tt>Textarea 1</tt> to <tt>Textarea 2</tt>?</strong> 
    <select onchange="eval('TA2.value='+options[selectedIndex].value)">
    <option value="TA2.value" selected="selected">-choose-</option>
    <option value="TA1.value"> yes </option>
    <option value="TA2.value||''"> no </option>
    </select>
    </p>
    <h3>Textarea 2</h3>
    <textarea name="TA2"></textarea>
    </form>
    </body>
    </html>

  • #3
    Regular Coder
    Join Date
    Aug 2003
    Location
    scotland, edinburgh
    Posts
    176
    Thanks
    5
    Thanked 1 Time in 1 Post
    thank you very much

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Ohh, eval again.
    That can be implemented without eval.
    Code:
    <select onchange="this.form.TA2.value=(this.selectedIndex==0)?this.form.TA1.value:''">
    <option> yes </option>
    <option selected="selected"> no </option>
    </select>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •