![]() |
| ||
| trying to append value to textarea with select box I'm trying to create a tag like routine for music genres. I have an array with various music genres in it. Those genres appear in a select box so they can be added to a text area... The problem is, I want to be able to add multiple genres instead of a new value replacing the old value. Heres sample code of what I have so far ... <?php Is there some subtle thing in "onCLick" I can change to get it to append the value?, ideally comma separated :-/ |
| ||
| Re: trying to append value to textarea with select box Hi, You can rephrase your onclick event handling like this. onClick="document.form1.tags.value +=document.form1.tagmenu.options[document.form1.tagmenu.selectedIndex].value; Here, I'm assuming that your onclick functionality is working fine :) In the above case, the options are added inline to the previous selection. To add options one below another you should add the /n after the += operator. Idea is to save the value of the textarea before changing its value. If want to add comma then you can use the followings onClick="document.form1.tags.value +=document.form1.tagmenu.options[document.form1.tagmenu.selectedIndex].value + ','; You can modify this according to your needs so that the "," does not appear un-necessarily. Another alternative is to provide your users the option of scrollable select with mulitiple select option. In that situation you will not require this button at all! To learn more about scrollable select which permits multiple selection you can refer the following link http://tutorialindia.com/html/html_select_element.php. Here you will need to use both of the select attributes, multiple as well as size. Hope this helps! |
| ||
| Re: trying to append value to textarea with select box Awesome thanks a lot! I figured it was something simple.. I'm just a javascript noob.. I kept trying to append like you do in PHP, with periods.. which of course didn't work. Thanks again ! |
| ||
| Re: trying to append value to textarea with select box I need to do a similar stuff, but I have no idea. Can u give some help or show me the way is your code working now? Appending from a mutiple select to the textarea box. Thanks any way! |
| ||
| Re: trying to append value to textarea with select box Let's play a simple demo, hope you find this useful... <html> <style type="text/css"> <script type="text/javascript"> </head> |
| All times are GMT -4. The time now is 10:46 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC