I'm building a form that first asks if you have 'foo'. If the answer is 'Yes', a div appears and asks 'How many foo do you have'? Based on the quantity answered, I'd like to show only that many divs. Thus if the user answers 1, only the first div will show. If they answer three, the first three will show. I have it set so that if the user answers no, the question of the amount remains hidden, but if they answer yes, they would be prompted for the quantity. This is what I've got so far...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<!--jQuery-->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<link rel="stylesheet" href="files/mem_health_panel.css" type="text/css" media="screen" />
<link rel="stylesheet" href="http://www.fabacherinteractive.com/slider/themes/default.css" type="text/css" media="screen" />
<style>
ul
{
list-style-type:none;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
$(window).load(function() {
$('#amt_of_foo,.foo_panels,.next').hide();
});
$('#yes_foo').click(function() {
$('#amt_of_foo').show();
});
$('#no_foo').click(function() {
$('.foo_panels,#amt_of_foo,.section_panel').hide();
$('.next').show();
});
});
</script>
</head>
<body>
<ul>
<li>
<div class="panel section_panel">
<h2>Questions About Your Foo</h2>
<span>Do you have foo?:</span><br />
<input type="radio" name="foo" id="no_foo" /> No <br />
<input type="radio" name="foo" id="yes_foo" /> Yes: <br/>
<span id="amt_of_foo">
<span>How many foo do you have?:</span>
<span><input id="qty_of_foo" type="text" size="5" />
</span>
</span>
</div>
</li>
<!--answers yes to foo, and enters amount-->
<div class="foo_panels">
<li>
<li>
<div class="panel foo_1">
<h1>First foo's information</h1>
<span>Foo name: <input type="text" size="20" /></span>
</div>
</li>
<li>
<div class="panel foo_2">
<h1>Second foo's information</h1>
<span>Foo name: <input type="text" size="20" /></span>
</div>
</li>
<li>
<div class="panel foo_3">
<h1>Third foo's information</h1>
<span>Foo name: <input type="text" size="20" /></span>
</div>
</li>
</div>
<!--answers no to foo-->
<li>
<div class="panel next">
<h1>Next Question, if no foo</h1>
</div>
</li>
</ul>
</body>
</html>
The ul is used for a jQuery 'slider' plugin. the 'panel' class is used for global css.