
June 3rd, 2004, 10:33 AM
|
|
Registered User
|
|
Join Date: Jun 2002
Posts: 17
Time spent in forums: 11 m 34 sec
Reputation Power: 0
|
|
Object Undefined Error
I have 6 drop-down boxes that are populated based on the user's previous selection. So if the user selects an item in #1, it will only show corresponding items in #2, so on and so forth. Once the user selects an item in #6, they then move to a textbox, which then refreshes the page in order to get the value selected in #6.
The problem I am encountering is when the user doesn't select any of the drop downs, but then clicks on the textbox. I get the "object undefined" error - which is meaningless to me (especially since the line #'s don't match up). I tried checking for "0", then inserting a default value, but this doesn't work.
Below the javascript functions for both the drop-downs and text box. Any assistance you can provide will be greatly appreciated.
Code:
Drop down:
function setLBValues(whichBoxSelected)
{
/*
---------------------------------------------------------------------------------------------
Set the list box selected values from the hidden form element values.
If this invocation was triggered by the static focus() code in the last Javascript (from
the server), the bsubmitFocus variable will be false and the form will not be submitted.
If this invocation was triggered by a setfocus() resulting from a mouse or keyboard event,
then bsubmitFocus will be true and the form will be submitted.
---------------------------------------------------------------------------------------------
*/
theBoxSelected = whichBoxSelected.name.charAt(3);
var lbStart = parseInt(theBoxSelected);
document.frmHWSW.lbFocus.value = theBoxSelected;
if (lbStart < 3)
{
endPoint = lbHWEnd;
}
else
{
endPoint = lbSWEnd;
}
document.frmHWSW.selBox0.value = document.frmHWSW.sel0.selectedIndex;
document.frmHWSW.selBox1.value = document.frmHWSW.sel1.selectedIndex;
document.frmHWSW.selBox2.value = document.frmHWSW.sel2.selectedIndex;
document.frmHWSW.selBox3.value = document.frmHWSW.sel3.selectedIndex;
document.frmHWSW.selBox4.value = document.frmHWSW.sel4.selectedIndex;
document.frmHWSW.selBox5.value = document.frmHWSW.sel5.selectedIndex;
document.frmHWSW.ListBoxNo.value = whichBoxSelected.name.charAt(3);
if (bsubmitFocus)
{
bsubmitFocus = false;
document.frmHWSW.submit();
}
else
{
bsubmitFocus = true;
}
}
Text Box:
function setBox5(whichBoxSelected)
{
theBoxSelected5 = 5
var lbStart = parseInt(theBoxSelected5);
document.frmHWSW.lbFocus.value = document.frmHWSW.HWStartYear;
document.frmHWSW.selBox5.value = document.frmHWSW.sel5.selectedIndex;
if (bsubmitFocus)
{
bsubmitFocus = false;
document.frmHWSW.submit();
}
else
{
bsubmitFocus = true;
}
}
|