I've got a simple function that that toggles the display of certain form fields. When I refresh the page, or post back, the display.value goes back to the original state. I don't know how to keep it on the selected state for refreshes and post backs. Please help. It's driving me crazy!

The javascript function:

function check_suspension()
{
	q = document.getElementById('suspension_0').checked;
	if (q)
	{
		document.getElementById('spdate').style.display='';
	}
	else
	{
		document.getElementById('spdate').style.display='none';
	}
}

The html code:


<tr class="row_even2">
<td class="td_left_small" style="width:177px;">
Suspension within 5 years?
</td>
<td style="text-align:left;padding-left:10px;">
<input id="suspension_0" name="Suspension" onchange="check_suspension();" type="radio" value="1"/>
<span style="cursor: default;">Yes</span>
<input id="suspension_1" name="Suspension" onchange="check_suspension();" type="radio" value="0"/>
<span style="cursor: default;">No</span>
</td>
</tr>
<tr class="row_even2" id="spdate" style="display: none;">
<td class="td_left_small" style="width:177px;">
Date of the suspension:
</td>
<td style="text-align:left;padding-left:10px;">
<input maxlength="2" name="SuspensionMonth" size="24" style="width: 20px" type="text" value=""/>&nbsp;/&nbsp;
<input maxlength="2" name="SuspensionDay" size="24" style="width: 20px" type="text" value=""/>&nbsp;/&nbsp;
<input maxlength="4" name="SuspensionYear" size="24" style="width: 40px" type="text" value=""/>
</td>
</tr>

Ok. Monday Detail. Make sure that style="display:none;" isn't in the table tags, and I changed onchange= to onclick=.

Yeah... That didn't work either. I just used a php if statement to toggle it and save the post values.

This question has already been answered. Start a new discussion instead.