Guys,
I have the following code in a HTML page. When the user selects an address from a drop down list then I want to change the value of a hidden variable. However, when I do this I get a JS error saying that "Object does not support this property or Method". The line the error refers to is the line where I have the select statement with the onChange event.
Can you please take a look at the code below and see if you can spot any errors.
<SCRIPT LANGUAGE="JavaScript">
<!--
function shipCode(shipaddr,shipCode) {
var select = eval(shipaddr.selectedIndex);
var catId = shipaddr.options[select].value;
var d = shipCode;
if (catId == 'STREET1, CITY1, COUNTRY1'){
d.value='ADDRESS1';
}
else if (catId == 'STREET2, CITY2, COUNTRY2'){
d.value='ADDRESS2';
}
} // end function
//-->
</SCRIPT>
</HEAD>
<BODY">
<FORM action="placeorder2.asp" method="post" name="OrderForm" onSubmit="return validate()">
<TABLE CELLPADDING=2 CELLSPACING=2 WIDTH='100%'>
</TR>
<TR>
<TD ALIGN=LEFT WIDTH=120 VALIGN=TOP><b>Ship To Address:</b></TD>
<TD ALIGN=LEFT><SELECT NAME="shiptoaddr" onChange="shipCode(document.OrderForm.shiptoaddr, document.OrderForm.shipCode)"><OPTION VALUE="STREET1, CITY1, COUNTRY1">STREET1, CITY1, COUNTRY1</OPTION>
<OPTION VALUE="STREET2, CITY2, COUNTRY2">STREET2, CITY2, COUNTRY2</OPTION>
</SELECT></TD></TR>
</TABLE>
<INPUT TYPE = "HIDDEN" NAME = "shipCode" VALUE = "ORBUS">
<TABLE>
<TR>
<TD ALIGN=CENTER COLSPAN=2><INPUT type="Submit" value="Proceed to Stage 2 -->" name="Submit"></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
Mise Le Meas,
Mighty
I have the following code in a HTML page. When the user selects an address from a drop down list then I want to change the value of a hidden variable. However, when I do this I get a JS error saying that "Object does not support this property or Method". The line the error refers to is the line where I have the select statement with the onChange event.
Can you please take a look at the code below and see if you can spot any errors.
<SCRIPT LANGUAGE="JavaScript">
<!--
function shipCode(shipaddr,shipCode) {
var select = eval(shipaddr.selectedIndex);
var catId = shipaddr.options[select].value;
var d = shipCode;
if (catId == 'STREET1, CITY1, COUNTRY1'){
d.value='ADDRESS1';
}
else if (catId == 'STREET2, CITY2, COUNTRY2'){
d.value='ADDRESS2';
}
} // end function
//-->
</SCRIPT>
</HEAD>
<BODY">
<FORM action="placeorder2.asp" method="post" name="OrderForm" onSubmit="return validate()">
<TABLE CELLPADDING=2 CELLSPACING=2 WIDTH='100%'>
</TR>
<TR>
<TD ALIGN=LEFT WIDTH=120 VALIGN=TOP><b>Ship To Address:</b></TD>
<TD ALIGN=LEFT><SELECT NAME="shiptoaddr" onChange="shipCode(document.OrderForm.shiptoaddr, document.OrderForm.shipCode)"><OPTION VALUE="STREET1, CITY1, COUNTRY1">STREET1, CITY1, COUNTRY1</OPTION>
<OPTION VALUE="STREET2, CITY2, COUNTRY2">STREET2, CITY2, COUNTRY2</OPTION>
</SELECT></TD></TR>
</TABLE>
<INPUT TYPE = "HIDDEN" NAME = "shipCode" VALUE = "ORBUS">
<TABLE>
<TR>
<TD ALIGN=CENTER COLSPAN=2><INPUT type="Submit" value="Proceed to Stage 2 -->" name="Submit"></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
Mise Le Meas,
Mighty