| | |
JavaScript Newbie - problem with style="display:" toggle
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Nov 2008
Posts: 4
Reputation:
Solved Threads: 0
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:
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=""/> /
<input maxlength="2" name="SuspensionDay" size="24" style="width: 20px" type="text" value=""/> /
<input maxlength="4" name="SuspensionYear" size="24" style="width: 40px" type="text" value=""/>
</td>
</tr>
The javascript function:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
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=""/> /
<input maxlength="2" name="SuspensionDay" size="24" style="width: 20px" type="text" value=""/> /
<input maxlength="4" name="SuspensionYear" size="24" style="width: 40px" type="text" value=""/>
</td>
</tr>
![]() |
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Problem Using innerHTML
- Next Thread: Merging 2 Arrays
Views: 1672 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
acid2 ajax ajaxcode ajaxhelp animate array automatically autoplay beta boarder box bug button calendar captcha card cart codes column cookies createrange() css cursor date debugger decimal design developer dom download dropdown element enter error events firefox firehose flash focus form frameworks getselection google gwt html htmlform iframe image() index java javascript javascripts jawascriptruntimeerror jquery jsp listbox maps marquee masterpage menu microsoft mimic mp3 mp4 offline onmouseover parameters php player post problem programming progressbar prototype rating redirect regex safari scale scriptlets search select size sources sql starrating text textarea toggle twitter validation variables w3c web website window windowofwords windowsxp xml xspf





