SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast mindaugas's Avatar
    Join Date
    Nov 2006
    Location
    Englewood, CO
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how can I select option and display in textarea

    I want to create a drop down select box and when an option is chosen it shots the text of my option to a textarea. Basically I am making a form for canned responses, I want to get these canned responses in a text area that can be ctrl'd a or hit select all button and copy/paste. thanks for any links or suggestions, code samples!
    More robots less humans

  2. #2
    SitePoint Member skiracer901's Avatar
    Join Date
    Aug 2004
    Location
    Indiana
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is a simple way that could be expanded on if necessary:

    HTML Code:
    <form name="item_form">
    
    <select name="items" onchange="document.forms.item_form.items_accumulated.value += this.options[selectedIndex].value;">
    	<option value="item1, ">Item 1</option>
    	<option value="item2, ">Item 2</option>
    	<option value="item3, ">Item 3</option>
    	<option value="item4, ">Item 4</option>
    	<option value="item5, ">Item 5</option>
    	<option value="item6, ">Item 6</option>
    </select>
    
    <textarea name="items_accumulated"></textarea>
    
    </form>
    Basically, when the user selects something from the SELECT box, it checks the VALUE attribute of the OPTION being selected and adds it to the textarea. Depending on what you're doing, you'll probably need to modify or even expand upon the code.


Bookmarks

Posting Permissions

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