
September 12th, 2009, 03:14 PM
|
|
Contributing User
|
|
Join Date: Apr 2007
Posts: 110
Time spent in forums: 1 Day 20 h 21 m 40 sec
Reputation Power: 3
|
|
|
Javascript - Optional Display Field error
HI,
I have managed to resolve the problem i had earlier, however i now have another problem, well in fact two.
Firstly when i select the correct field from the drop down menu the required additional five fields are displayed. However if i then try and change back to the other value in the drop down menu the aditinal fields do not disappear like they are supposed to and i can't sem to find why.
Secondly this all works locally in my browser, but as soon as i upload it to my website it stops working.
If anybody has any ideas or suggestions then i would be grateful for any direction.
Thanks
Stan
Code:
<!--
function displayoptional(){
var a= document.forms['capform'].elements['camper'].value
if(a ='camper'){
document.getElementById('optional').style.display = '';
}
else if(a ='owner')
{
document.getElementById('optional').style.display = 'none';
}//endif
}//end displayoptional function
Code:
<form action="register.php" method="post" name="capform" class="FormGeneric" onSubmit="return capCheck(this);">
<table width="400" border="0">
<tr>
<td width="142"> </td>
<td width="248"><select name="camper" id="camper" onchange='displayoptional()'>
<option value="camper">Camper</option>
<option value="owner">Owner</option>
</select></td>
</tr>
<tr>
<td>Email Address</td>
<td><span style="width:275px">
<input type="text" name="email_address" size="30" value="[var.email_address]" />
</span></td>
</tr>
<tr>
<td>Username</td>
<td><span style="width:275px">
<input type="text" name="user_name" size="20" value="[var.user_name]" />
</span></td>
</tr>
<tr>
<td>Password</td>
<td><span style="width:275px">
<input type="password" name="password" size="20" value="[var.password]" />
</span></td>
</tr>
<tr>
<td>Confirm Password</td>
<td><input type="password" name="confirm_password" size="20" value="[var.confirm_password]" /></td>
</tr>
</table>
<div style='display:none' id='optional'>
<table width="400" border="0">
<tr>
<td>Mobile Number</td>
<td><input type="text" name="mobile_number" size="20" value="[var.mobile_number]" /> </td>
</tr>
<tr>
<td>Phone Number</td>
<td><input type="text" name="phone_number" size="20" value="[var.phone_number]" /> </td>
</tr>
<tr>
<td>Address </td>
<td><input type="text" name="address" size="20" value="[var.address]" /> </td>
</tr>
<tr>
<td>Postcode </td>
<td><input type="text" name="postcode" size="20" value="[var.postcode]" /> </td>
</tr>
<tr>
<td>Choice </td>
<td><input type="text" name="camping_choice" size="20" value="[var.camping_choice]" /> </td>
</tr>
</table>
</div>
<table width="400" border="0">
<tr>
<td width="143">Select to agree</td>
<td width="247"><span style="width:275px">
<input type="radio" value="yes" name="terms" [var.checked] />
<a href="page.php?page=3" target="_blank">Our terms</a></span></td>
</tr>
<tr>
<td><img src="image.php" alt="" name="capimage" border="0" id="capimage" /></td>
<td><span style="width:150px; text-align:left">
<input type="text" value="" name="captext" size="17" />
</span></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Register" name="registe_r"/>
<input type="hidden" name="form_submitted" value="yes" />
</td>
</tr>
</table>
</form>
|