I am getting a reference error that "theSelect" is undefined. I don't know why it says that, as it is defined in the code.
the code is fed a state name through the onclick function of a radio button.
onclick= "oregeno('oregon');"
it then calls the code
function oregeno(state)
{
if (state="oregon")
{
var Options = ["Portland", "Salem", "Corvallis", "Bend","Eugene","Ashland" ];
}
else
{
var Options= ["Seattle", "Olympia", "Yakima", "Walla Walla", "Spokane", "White Salmon"] ;
}
var mypara=document.getElementById('paraplace');
var theform=document.createElement('form');
var theSelect=document.createElement('select');
nowOnChange=new Function("e","location.href=theSelect.options[theSelect.selectedIndex].value");
var theOption=document.createElement("OPTION");
var theText=document.createTextNode("choose city");
theOption.appendChild(theText);
theSelect.appendChild(theOption)
for (l=0; l< Options.length; l++)
{
theOption=document.createElement("OPTION");
theText=document.createTextNode(Options[l]);
theOption.setAttribute("value", Options[l]+".htm")
theSelect.appendChild(theOption);
}
theform.appendChild(theSelect);
mypara.appendChild(theform);
theSelect.onchange=nowOnChange;
}
the page renders, but when I select the state, I get a drop down with what looks like 6 members. But all the options are empty. When I choose one of the empty options, I get the error.
Thanks for your help. This place has been great.