View Full Version : New problems with a form

06-14-2010, 03:13 PM
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
e.style.display = 'block';

<img id="top" src="top.png" alt="">
<div id="form_container">
<h1><a>Test Page</a></h1>
<form id="form_250840" class="appnitro" method="post" action="">
<div class="form_description">

<h2>TEST PAGE</h2>

<div id="li_17" >
<label class="description" for="element_17">Sample Question 1? </label>

<input type="radio" id="element_17_yes" name="element_17" class="element radio" value="yes" onclick="document.getElementById('li_17a').style.display='block';" />
<label class="choice" for="element_17_yes">Yes</label>
<input type="radio" id="element_17_no" name="element_17" class="element radio" value="no" checked="checked" onclick="document.getElementById('li_17a').style.display='none';" />
<label class="choice" for="element_17_no">No</label>

<div id="li_17a" >
<label class="description" for="element_17a">Sample Question 2? </label>
<span><input id="element_17_1a" name="element_17a" class="element radio" type="radio" value="1" />
<label class="choice" for="element_17_1a">Yes</label>
<input id="element_17_2a" name="element_17a" class="element radio" type="radio" value="2" checked="checked"/>
<label class="choice" for="element_17_2a">No</label></span>

<li class="buttons">
<input type="hidden" name="form_id" value="250840" />
<input id="saveForm" class="button_text" type="submit" name="submit" value="Submit" />

Ok, my problem I seem to be having is that I want "sample question 2" to be invisible unless someone answers yes to "sample question 1". I've tried coding an onclick script into the radio buttons but I can't seem to get it working. I know this shouldn't be that difficult. Anyone know how to fix it?

Old Pedant
06-14-2010, 11:17 PM
You just forgot to iniitialize the div to non-display.

That is:

<div id="li_17a" style="display: none;">

Then it works fine.