SELECT values always returned as undefined

wxdqz

New Member
Hi, I am writing a page in ASP and using a lot of JavaScript. I have a SELECT input that I need to get the value of and either
enable or disable another control based on what the value of the SELECT input is. I am trying to do this from the SELECT
input's ONCHANGE event. I am getting very frustrated b/c no matter what I do, the value of the SELECT input is always
returned to me as undefined.

I have two functions in a JavaScript file that I am using from my ASP page. The first simply populates the SELECT input
with a list of values. The second is the function that is executed from the SELECT input's ONCHANGE event.

Here is how I am calling these two functions from the ASP code:

<SELECT NAME = lstWhyDischarged TITLE = "Select reason for discharge" ONFOCUS="wStatus(this);" ONCHANGE="f_lstWhyDischarged(this);" ONBLUR="checkRequired(this);">
<SCRIPT LANGUAGE = "JavaScript" TYPE = "text/javascript">
document.write(optionWhyDischarged("<%'=strWhyDischarged%>"));
</SCRIPT>
</SELECT>


Here is the function that puts the values into the SELECT input:

function optionWhyDischarged(optionToSelect)
{
var returnValue="";

returnValue += "<OPTION value=''></OPTION>";

returnValue += (optionToSelect == "1") ? "<OPTION value=http://www.webdeveloper.com/forum/archive/index.php/1 selected=true>Failed to meet employer's standards</OPTION>" : "<OPTION value=http://www.webdeveloper.com/forum/archive/index.php/1>Failed to meet employer's standards</OPTION>";

returnValue += (optionToSelect == "2") ? "<OPTION value=http://www.webdeveloper.com/forum/archive/index.php/2 selected=true>Job performance/negligence</OPTION>" : "<OPTION value=2>Job performance/negligence</OPTION>";

returnValue += (optionToSelect == "3") ? "<OPTION value=3 selected=true>Arguing with employer</OPTION>" : "<OPTION value=3>Arguing with employer</OPTION>";

returnValue += (optionToSelect == "4") ? "<OPTION value=4 selected=true>Left work without permission</OPTION>" : "<OPTION value=4>Left work without permission</OPTION>";

returnValue += (optionToSelect == "5") ? "<OPTION value=5 selected=true>Lost license</OPTION>" : "<OPTION value=5>Lost license</OPTION>";

returnValue += (optionToSelect == "6") ? "<OPTION value=6 selected=true>Loafing</OPTION>" : "<OPTION value=6>Loafing</OPTION>";

returnValue += (optionToSelect == "7") ? "<OPTION value=7 selected=true>Profane language</OPTION>" : "<OPTION value=7>Profane language</OPTION>";

returnValue += (optionToSelect == "8") ? "<OPTION value=8 selected=true>Horseplay</OPTION>" : "<OPTION value=8>Horseplay</OPTION>";

returnValue += (optionToSelect == "9") ? "<OPTION value=9 selected=true>Customer complaints</OPTION>" : "<OPTION value=9>Customer complaints</OPTION>";

returnValue += (optionToSelect == "10") ? "<OPTION value=10 selected=true>Dishonesty</OPTION>" : "<OPTION value=10>Dishonesty</OPTION>";

returnValue += (optionToSelect == "11") ? "<OPTION value=11 selected=true>Cash register shortages</OPTION>" : "<OPTION value=11>Cash register shortages</OPTION>";

returnValue += (optionToSelect == "12") ? "<OPTION value=12 selected=true>Other</OPTION>" : "<OPTION value=12>Other</OPTION>";

return returnValue;

}//optionWhyDischarged


Here is the function that I call in the ONCHANGE event:

function f_lstWhyDischarged(oField)
{
var blDisabled = false;
if(oField.Value != "12")
{
blDisabled = false;
}

enableDisable(document.forms[0].txtWhyOther,blDisabled);

return;
}


Does anybody see anything that I'm doing wrong? The value returned by the SELECT input is always undefined. I'm at my wit's end. Please help me.

Thank You,
Crystal
 
Back
Top