Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

adding list box items into text boxes 2

Status
Not open for further replies.

arlequin

Programmer
Sep 21, 1999
232
UY
Hi, people!<br><br>I need some help in this:<br>Have a page where there are a few items in a list box and I want to insert them one by one&nbsp;&nbsp;into few text boxes by pressing the &quot;Add&quot; button.<br>In the other hand, each text box has a button side by side that cleans the current text box, I mean, if it is filled with a name and I press the button, it gets cleaned and available for new inputs.<br>I must build an iteration to check out every text box in the table and insert the text from the list box into the first free text box I find...<br><br>Am I clear?<br><br>THANX in ADVANCE
 
Dear Arlequin,<br><br>&gt; Am I clear?<br><br>Almost, what browsers do you have to support?<br><br>In IE this would be simple since you can name all of the textboxes the same then access them using the document.all collection: <br><br>// inside onchange handler for the list<br>var oList = window.event.srcElement;<br><br>var bdone = false;<br>for( i=0; !bdone && i&lt;document.all(&quot;mytext&quot;).length; i++){<br>&nbsp;&nbsp;var ele = document.all(&quot;mytext&quot;, i);<br>&nbsp;&nbsp;var sval = new String(ele.value);<br>&nbsp;&nbsp;if ( 0 == sval.length ){<br>&nbsp;&nbsp;&nbsp;&nbsp;ele.value = oList.value;<br>&nbsp;&nbsp;&nbsp;&nbsp;bdone = true;<br>&nbsp;&nbsp;}<br>}<br><br>&quot;but that's just my opinion... I could be wrong&quot;.<br>-pete
 
If you only have one textarea, with the name <i>myTextArea</i> and you have only one list box with the name <i>myListBox</i> and, both of them are in the form <i>myCoolForm</i> then:<br><br>function moveToText(){<br>var myLB=document.myCoolForm.myListBox<br>var myTA=document.myCoolForm.myTextArea<br>var currentOption;<br>for (i=0;i&lt;myLB.options.length;i++){<br>currentOption=myLB.options<i>;<br>myTA.text+=currentOption.text+'\n';<br>}<br>}<br><br>and<br><br>function clearTextArea(){<br>var myTA=document.myCoolForm.myTextArea;<br>myTA.text=''<br>}<br><br>that <u>should</u> work <p>theEclipse<br><a href=mailto:eclipse_web@hotmail.com>eclipse_web@hotmail.com</a><br><a href=robacarp.webjump.com>robacarp.webjump.com</a><br>**-Trying to build a documentation of a Javascript DOM, crossbrowser, of course. E-mail me if you know of any little known events and/or methods, etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top