Hi,<br>I have two list boxes on my form. What i need to do is to add the values selected in the first list box to the second list box. Both have multiple selection option enabled.<br><br>Thanks in advance
Dear kirankumar,<br><br>Where your form is named 'form1' and your two 'select' elements are named 'select1' and 'select2' this would work:<br><br>function cmdCopy_onclick() {<br><br> for(i=0;i<document.form1.select1.options.length; i++){<br> document.form1.select2.options.add( <br> document.form1.select1.options(i));<br> }<br>}<br><br>Good luck<br>-pete<br>
Dear Pete,<br><br>I tried with the same code. But its not working. I am getting the alert but not the new values in select box2. Here is the code in the command button click event.<br><br>function assign()<br>{<br>var intlength;<br>intlength=window.document.frmassign.select1.options.length;<br>alert(intlength);<br>var temp;<br>for (var i = 0; i < intlength; i++)<br>{<br>temp = window.document.frmassign.select1.options(i).value;<br>alert(temp); <br>window.document.frmassign.select2.options.add(window.document.frmassign.select1.options(i));<br>} <br>}<br><br>I already done the same thing. But somewhere it's going wrong. <br>Thank you for your help and time.<br><br>Kiran<br>
yes, replace that part :<br><br>temp = window.document.frmassign.select1.options(i).value;<br>window.document.frmassign.select2.options.add(window.document.frmassign.select1.options(i));<br><br>------<br>with that one :<br>var temp = window.document.frmassign.select1.options(i).value;<br>var temp2 = window.document.frmassign.select1.options(i).text;<br>var oOption = document.createElement("OPTION"<br>oOption.text=temp;<br>oOption.value=temp2;<br>window.document.frmassign.select2.options.add(oOption)<br><br><br>and it might b ok<br>tell me if it's not
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.