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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Interrogating values in a multiple select box

Status
Not open for further replies.

jpember

Programmer
May 1, 2002
21
ZA
Can anyone out there tell me how I can read through all the values in a multiple select box in a loop?
I have managed to get the user to enter values in a textbox, click on a button to add the value to the end of a listbox, but now I want to be able to insert a new record into my database for each value that has been added.
I am using VBScript to do this but can't find any help specifically to do this.

Thanks in advance,
Jacqui
 
This will work:

<select id=&quot;select1&quot;>
<option value=&quot;first val=a&quot;>a</option>
<option value=&quot;first val=b&quot;>b</option>
<option value=&quot;first val=c&quot;>c</option>
<option value=&quot;first val=d&quot;>d</option>
</select>
<script>
<!--
var arr=new Array();
for(i=0;i<select1.options.length; i++){
arr=select1.options.value;
}
for(i=0;i<arr.length; i++){
alert(arr);
}
//-->
</script>

Then all the values should be stored in the array &quot;arr&quot;. The last for() part runs off the alerts. (that's there only for testing--you can take it out)

Rick if(($question==&quot;has been bugging me&quot;
AND $answer==&quot;fixed the problem&quot;) OR $answer==&quot;really good post&quot;){
print(&quot;Star&quot;);
}else{
print(&quot;Thanks.&quot;);
}
 
Thanks Rick - I understand what you've given me. How does this fit in with the form object that I'm using to pick up the values?
i.e. how can I refer to the list box or array using the Request.Form(&quot;fieldname&quot;) method/function?
I want to evaluate all the values on the server side after the user has clicked on the submit button.
Rgds,
Jacqui
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top