liamloveslearning Posted June 7, 2010 Share Posted June 7, 2010 Im not sure if this is in the correct board so apologies, Ive been having trouble trying to insert multiple values into 1 field, my way around it, and a more aesthetically pleasing look, is to have to boxes, an empty one and 1 with a list of predefined variables, I want to click one of the variables for it to then shoot across to the other text area, pouplating it on each click, does this make sense? Quote Link to comment Share on other sites More sharing options...
liamloveslearning Posted June 7, 2010 Author Share Posted June 7, 2010 Ive come accross this which does exactly as I need, only it doesnt populate more than 1 value. Im a complete amateur with javascript so if anybody could pooint me in the right direction id be so greatful <form name="form1"> <select style="background-color: transparent; font-size: 10px; color: rgb(0, 102, 153); font-family: verdana;" name="menu"> <option value="#">Quick Links ...</option> <option value="This is for value no.1">Value No. 1</option> <option value="This is for value no.2">Value No. 2</option> <option value="This is for value no.3">Value No. 3</option> <option value="This is for value no.4">Value No. 4</option> <option value="This is for value no.5">Value No. 5</option> <option value="This is for value no.6">Value No. 6</option> </select> <input style="font-size: 8pt; color: rgb(255, 255, 255); font-family: verdana; background-color: rgb(0, 102, 153);" value="Populate" type="button" onClick="document.form1.accept.value=document.form1.menu.options[document.form1.menu.selectedIndex].value;document.form1.textareaaccept.value=document.form1.menu.options[document.form1.menu.selectedIndex].value;"> <br/> <br/> <textarea type="text" name="accept" style="width:200px;"></textarea> <br/> </form> Quote Link to comment Share on other sites More sharing options...
Adam Posted June 8, 2010 Share Posted June 8, 2010 What do you mean by multiple values..? value1, value2, value3 So every time you select some text, it inserts them like above (or similar)? Quote Link to comment Share on other sites More sharing options...
ScotDiddle Posted June 8, 2010 Share Posted June 8, 2010 liamloveslearning, See if the following does what you want. Let us know. <?php Header("Cache-control: private, no-cache"); Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); Header("Pragma: no-cache"); ?> <html> <head> <script type="text/javascript"> function addText() { if (document.form1.menu.options[document.form1.menu.selectedIndex].value != '#') { // Don't write "Quick Links" to text area... // Magic Happens with the "+=" operator document.form1.accept.value += document.form1.menu.options[document.form1.menu.selectedIndex].value + "\n"; alert(document.form1.accept.value); // document.form1.textarea.accept.value=document.form1.menu.options[document.form1.menu.selectedIndex].value; } } </script> </head> <body> <form name="form1"> <select onChange="addText();" style="background-color: transparent; font-size: 10px; color: rgb(0, 102, 153); font-family: verdana;"name="menu"> <option id="val[]" name="val[]" value="#">Quick Links ...</option> <option id="val[]" name="val[]" value="This is for value no.1">Value No. 1</option> <option id="val[]" name="val[]" value="This is for value no.2">Value No. 2</option> <option id="val[]" name="val[]" value="This is for value no.3">Value No. 3</option> <option id="val[]" name="val[]" value="This is for value no.4">Value No. 4</option> <option id="val[]" name="val[]" value="This is for value no.5">Value No. 5</option> <option id="val[]" name="val[]" value="This is for value no.6">Value No. 6</option> </select> <span width="50px;"> Text -> </span> <textarea type="text" id="accept" name="accept" style="width:275px; height:175px;"></textarea> <br/> </form> </body> </html> Hope it helps. Scot L. Diddle, Richmond VA Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.