hi,
i need to make a select statement show more fields depending on what i have selected. what it's supposed to do is show or hide a div depending on selection
here is the javascript ----------------------------
<script language=javascript type='text/javascript'>
function hideRent() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('rentform').style.visibility = 'hidden';
}
else {
if (document.layers) { // Netscape 4
document.rentform.visibility = 'hidden';
}
else { // IE 4
document.all.rentform.style.visibility = 'hidden';
}
}
}
function hideSale() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('saleform').style.visibility = 'hidden';
}
else {
if (document.layers) { // Netscape 4
document.saleform.visibility = 'hidden';
}
else { // IE 4
document.all.saleform.style.visibility = 'hidden';
}
}
}
function showRent() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('rentform').style.visibility = 'visible';
}
else {
if (document.layers) { // Netscape 4
document.rentform.visibility = 'visible';
}
else { // IE 4
document.all.rentform.style.visibility = 'visible';
}
}
}
function showSale() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('saleform').style.visibility = 'visible';
}
else {
if (document.layers) { // Netscape 4
document.saleform.visibility = 'visible';
}
else { // IE 4
document.all.saleform.style.visibility = 'visible';
}
}
}
</script>
----------------------------------------------------------
here is the html ----------------------------------------
<td><SELECT name="saleorrental">
<option value="">Please select</option>
<option value="sale" onchange="showSale()">Sale</option>
<option value="rental" onchange="showRent()">Rental</option>
</SELECT></td>
</tr>
<div id="saleform">
<? if ($saleorrental == "sale"){ ?>
<tr valign="top">
<td><font color="#FF0000">*</font>Price</td>
<td> <input name="price" type="text" id="price"> </td>
</tr>
<tr valign="top">
<td><font color="#FF0000">*</font>Buy Costs</td>
<td><input name="buycosts" type="text" id="buycosts"></td>
</tr>
<tr valign="top">
<td><font color="#FF0000">*</font>Expected re-sale</td>
<td><input name="expectedresale" type="text" id="expectedresale"></td>
</tr>
<tr>
<td> </td>
<td><font color="#FF0000">* </font>Mandatory Fields </td>
</tr>
<tr>
<td> <input type="submit" name="Submit" value="Submit"> <input type="reset"
name="cancel" value="Reset"> </td>
<td> </td>
</tr>
</div>
<!--<? } if ($saleorrental == "rent"){ ?>-->
<div id="rentform">
<tr align="left" valign="top">
<td class="results">Rent PCM:</td>
<td colspan="2" class="results"><input name="rent" type="text" id="rent">
</td>
</tr>
<tr align="left" valign="top">
<td class="results">Mortgage:</td>
<td colspan="2" class="results"><input name="mortgage" type="text" id="expectedresale3">
</td>
</tr>
<tr>
<td> </td>
<td><font color="#FF0000">* </font>Mandatory Fields </td>
</tr>
<tr>
<td> <input type="submit" name="Submit" value="Submit"> <input type="reset"
name="cancel" value="Reset"> </td>
<td> </td>
</tr>
</div>
----------------------------------------------------------
does anyone know how to make it work or know of a better way to do it?
thanks
i need to make a select statement show more fields depending on what i have selected. what it's supposed to do is show or hide a div depending on selection
here is the javascript ----------------------------
<script language=javascript type='text/javascript'>
function hideRent() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('rentform').style.visibility = 'hidden';
}
else {
if (document.layers) { // Netscape 4
document.rentform.visibility = 'hidden';
}
else { // IE 4
document.all.rentform.style.visibility = 'hidden';
}
}
}
function hideSale() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('saleform').style.visibility = 'hidden';
}
else {
if (document.layers) { // Netscape 4
document.saleform.visibility = 'hidden';
}
else { // IE 4
document.all.saleform.style.visibility = 'hidden';
}
}
}
function showRent() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('rentform').style.visibility = 'visible';
}
else {
if (document.layers) { // Netscape 4
document.rentform.visibility = 'visible';
}
else { // IE 4
document.all.rentform.style.visibility = 'visible';
}
}
}
function showSale() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('saleform').style.visibility = 'visible';
}
else {
if (document.layers) { // Netscape 4
document.saleform.visibility = 'visible';
}
else { // IE 4
document.all.saleform.style.visibility = 'visible';
}
}
}
</script>
----------------------------------------------------------
here is the html ----------------------------------------
<td><SELECT name="saleorrental">
<option value="">Please select</option>
<option value="sale" onchange="showSale()">Sale</option>
<option value="rental" onchange="showRent()">Rental</option>
</SELECT></td>
</tr>
<div id="saleform">
<? if ($saleorrental == "sale"){ ?>
<tr valign="top">
<td><font color="#FF0000">*</font>Price</td>
<td> <input name="price" type="text" id="price"> </td>
</tr>
<tr valign="top">
<td><font color="#FF0000">*</font>Buy Costs</td>
<td><input name="buycosts" type="text" id="buycosts"></td>
</tr>
<tr valign="top">
<td><font color="#FF0000">*</font>Expected re-sale</td>
<td><input name="expectedresale" type="text" id="expectedresale"></td>
</tr>
<tr>
<td> </td>
<td><font color="#FF0000">* </font>Mandatory Fields </td>
</tr>
<tr>
<td> <input type="submit" name="Submit" value="Submit"> <input type="reset"
name="cancel" value="Reset"> </td>
<td> </td>
</tr>
</div>
<!--<? } if ($saleorrental == "rent"){ ?>-->
<div id="rentform">
<tr align="left" valign="top">
<td class="results">Rent PCM:</td>
<td colspan="2" class="results"><input name="rent" type="text" id="rent">
</td>
</tr>
<tr align="left" valign="top">
<td class="results">Mortgage:</td>
<td colspan="2" class="results"><input name="mortgage" type="text" id="expectedresale3">
</td>
</tr>
<tr>
<td> </td>
<td><font color="#FF0000">* </font>Mandatory Fields </td>
</tr>
<tr>
<td> <input type="submit" name="Submit" value="Submit"> <input type="reset"
name="cancel" value="Reset"> </td>
<td> </td>
</tr>
</div>
----------------------------------------------------------
does anyone know how to make it work or know of a better way to do it?
thanks