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="button" name="submit" value="Select County"
onClick="selectCounty(this.form.county)" class="btnGenerate">
Here is my call function:
function selectCounty(theList) {
var i = theList.selectedIndex
if (i == -1) return false // no county selected
getMultipleOptionValues(i );
var url = "../repsco.html?co~" + optval + "~" + escape(opttxt)
goToLocation(url)
return true
}
====================
function getMultipleOptionValues(list,dlim) {
var vlist = "";
var vtext = "";
var vdlim = ";";
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
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="button" name="submit" value="Select County"
onClick="selectCounty(this.form.county)" class="btnGenerate">
Here is my call function:
function selectCounty(theList) {
var i = theList.selectedIndex
if (i == -1) return false // no county selected
getMultipleOptionValues(i );
var url = "../repsco.html?co~" + optval + "~" + escape(opttxt)
goToLocation(url)
return true
}
====================
function getMultipleOptionValues(list,dlim) {
var vlist = "";
var vtext = "";
var vdlim = ";";
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