Sample script
<SCRIPT LANGUAGE="JavaScript">I tried setting a global variable to equal "chosen" but when I run the page it tells me that global variable is undefined. So my question is how do I define a local variable to be equal to a global variable, so that when I leave the function "chosen" still has a value.
function GetSelectedItem() {
len = document.formname.selectname.length
i = 0
chosen = "none"
for (i = 0; i < len; i++) {
if (document.formname.selectname[i].selected) {
chosen = document.formname.selectname[i].value
}
}
//return chosen
alert(chosen);
}
</script>
My best guess is the following script.
<SCRIPT LANGUAGE="JavaScript">But sadly that scripts doesn't work. Any help would be greatly appreciated, even if you just give me a google phrase so that I can search the answer myself.
function GetSelectedItem() {
len = document.zonepick.zonebox.length
i = 0
chosen = "none"
for (i = 0; i < len; i++) {
if (document.zonepick.zonebox[i].selected) {
chosen = document.zonepick.zonebox[i].value;
_global.thezone = chosen;
}
}
//return chosen
//alert(chosen);
}
alert(thezone);
</script>
Ben