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!

loading multiple values from a select list

Status
Not open for further replies.

tennis

Technical User
Aug 23, 2001
18
US
Hi,

I have an html form that has multiple select options and I am trying to pass all of the selections into a generic JavaScript function to build a URL

The call to the javascript is as follows:
<input type=&quot;button&quot; name=&quot;submit&quot; value=&quot;Select County&quot;
onClick=&quot;selectCounty(this.form.county)&quot; class=&quot;btnGenerate&quot;>

Here is my call function:
function selectCounty(theList) {
var i = theList.selectedIndex
if (i == -1) return false // no county selected
getMultipleOptionValues(i );
var url = &quot;../repsco.html?co~&quot; + optval + &quot;~&quot; + escape(opttxt)
goToLocation(url)
return true
}
====================
function getMultipleOptionValues(list,dlim) {
var vlist = &quot;&quot;;
var vtext = &quot;&quot;;
var vdlim = &quot;;&quot;;
var n = 0;
if (list) { // can't do anything if the list doesn't exist
if ((dlim) && (!isEmpty(dlim))) vdlim = dlim;
for (var i=0; i<list.length; i++) {
if ((list.options.selected) && (!isEmpty(list.options.value))) {
n++;
if (n > 1) vlist += vdlim;
vlist += list.options.value;
vtext += list.options.text;
}
}
optval = vlist;
opttxt = vtext;
}
return n ;
}
============
optval and opttxt are both global variables. , how do I get it to return all of the selections?

Thanks in advance

 
Thanks,

I think I figured it out -- I was sending the index vs. theList.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top