here is my code to use select box to change other text fields in the same form. I can't figure out why it's not working. it would be great if you can help me out. basically the select button allows you to choose an apartment type. and other text fields representing various features of the chosen apartment type should be filled with relevent info when select box changes.
sample code:
<FORM ACTION="Apartment_search.asp" METHOD="POST" name="information">
<TABLE WIDTH="300" BORDER="1" bgcolor="#C0C0C0" bordercolor="#696969" cellpadding="0" cellspacing="0">
<!-- This is the javascript for apt. search menu -->
<script language="javascript">
function setvals() {
if ( document.information.apt_type.value == 1 ) {
document.information.Bedroom.value = "1";
document.information.Bathroom.value = "1";
} else if ( document.information.apt_type.value == 2 ) {
document.information.Bedroom.value = "1";
document.information.Bathroom.value = "2";
} else {
}
}
</script>
<TR>
<TD VALIGN="Top"><b><u>Apartment Type</u></b></TD>
<TD VALIGN="Top">
<select name="apt_type" onChange="setvals()">
<option value="0">-- None --</option>
<option value="1">Studio Reg</option>
<option value="2">Studio Prem</option>
</select>
</TD>
</TR>
<TR>
<TD VALIGN="Top"><b><u>Bed Room</U></b></TD>
<TD VALIGN="Top"><INPUT TYPE="text" NAME="Bedroom" size="2" maxlength="2"></TD>
</TR>
<TR>
<TD VALIGN="Top"><b><u>bathroom</u></b></TD>
<TD VALIGN="Top"><INPUT TYPE="text" NAME="Bathroom" size="2" maxlength="2" value=""></TD>
</TR>
<TR>
<TD VALIGN="Top"></TD>
<TD VALIGN="Top"><INPUT TYPE="submit" VALUE="Search"></TD>
</TR>
</TABLE>
</FORM>
sample code:
<FORM ACTION="Apartment_search.asp" METHOD="POST" name="information">
<TABLE WIDTH="300" BORDER="1" bgcolor="#C0C0C0" bordercolor="#696969" cellpadding="0" cellspacing="0">
<!-- This is the javascript for apt. search menu -->
<script language="javascript">
function setvals() {
if ( document.information.apt_type.value == 1 ) {
document.information.Bedroom.value = "1";
document.information.Bathroom.value = "1";
} else if ( document.information.apt_type.value == 2 ) {
document.information.Bedroom.value = "1";
document.information.Bathroom.value = "2";
} else {
}
}
</script>
<TR>
<TD VALIGN="Top"><b><u>Apartment Type</u></b></TD>
<TD VALIGN="Top">
<select name="apt_type" onChange="setvals()">
<option value="0">-- None --</option>
<option value="1">Studio Reg</option>
<option value="2">Studio Prem</option>
</select>
</TD>
</TR>
<TR>
<TD VALIGN="Top"><b><u>Bed Room</U></b></TD>
<TD VALIGN="Top"><INPUT TYPE="text" NAME="Bedroom" size="2" maxlength="2"></TD>
</TR>
<TR>
<TD VALIGN="Top"><b><u>bathroom</u></b></TD>
<TD VALIGN="Top"><INPUT TYPE="text" NAME="Bathroom" size="2" maxlength="2" value=""></TD>
</TR>
<TR>
<TD VALIGN="Top"></TD>
<TD VALIGN="Top"><INPUT TYPE="submit" VALUE="Search"></TD>
</TR>
</TABLE>
</FORM>