robbymo
05-09-2007, 01:42 AM
I am trying to implement a dynamic form and can not get the questions to be initially hidden, showing only after a Problem is chosen.
Each question should be able to be shown/hidden individually. The group of questions to display for each Problem should be designated in an array, which is used with a show/hide function to show or hide each question as desired, depending on what group is active
I have it where there hidden but can't get them back.....
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>
Dynamic Form
</title>
<style>
.Question {
display:none;
}
</style>
<script language="JavaScript" type="text/javascript">
<!--
function ShowHide(sel){
for (var zxc0=1;zxc0<4;zxc0++){
for (var zxc0a=1;zxc0a<6;zxc0a++){
if (document.getElementById('s'+zxc0+'q'+zxc0a)){
document.getElementById('s'+zxc0+'q'+zxc0a).style.display=(zxc0==sel.value)?'':'none';
}
}
}
}
//-->
</script>
</head>
<body>
choose problem that is happening from the list.<br>
<select name="problem" size="1" onChange="ShowHide(this)">
<option value="1">
Problem 1
</option>
<option value="2">
Problem 2
</option>
<option value="3">
Problem 3
</option>
</select>
</td>
<td>
<div id="s1q1" class="Question">
Question1 Set1:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
<div id="s1q2" class="Question">
Question2:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
<div id="s1q3" class="Question">
Question3:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
<div id="s1q4" class="Question">
Question4:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
<div id="s1q5" class="Question">
Question5:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
<!--
<div id="s2q1 class="Question">
Question1Set2:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
<div id="s2q2 class="Question">
Question2:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
<div id="s2q3 class="Question">
Question3:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
<div id="s2q4 class="Question">
Question4:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
<div id="s2q5 class="Question">
Question5:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
<div id="s3q1 class="Question">
Question1set3:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
<div id="s3q2 class="Question">
Question2:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
<div id="s3q3 class="Question">
Question3:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
<div id="s3q4 class="Question">
Question4:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
<div id="s3q5 class="Question">
Question5:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
-->
</form>
</td>
</div>
</body>
</html>
</body>
Each question should be able to be shown/hidden individually. The group of questions to display for each Problem should be designated in an array, which is used with a show/hide function to show or hide each question as desired, depending on what group is active
I have it where there hidden but can't get them back.....
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>
Dynamic Form
</title>
<style>
.Question {
display:none;
}
</style>
<script language="JavaScript" type="text/javascript">
<!--
function ShowHide(sel){
for (var zxc0=1;zxc0<4;zxc0++){
for (var zxc0a=1;zxc0a<6;zxc0a++){
if (document.getElementById('s'+zxc0+'q'+zxc0a)){
document.getElementById('s'+zxc0+'q'+zxc0a).style.display=(zxc0==sel.value)?'':'none';
}
}
}
}
//-->
</script>
</head>
<body>
choose problem that is happening from the list.<br>
<select name="problem" size="1" onChange="ShowHide(this)">
<option value="1">
Problem 1
</option>
<option value="2">
Problem 2
</option>
<option value="3">
Problem 3
</option>
</select>
</td>
<td>
<div id="s1q1" class="Question">
Question1 Set1:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
<div id="s1q2" class="Question">
Question2:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
<div id="s1q3" class="Question">
Question3:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
<div id="s1q4" class="Question">
Question4:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
<div id="s1q5" class="Question">
Question5:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
<!--
<div id="s2q1 class="Question">
Question1Set2:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
<div id="s2q2 class="Question">
Question2:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
<div id="s2q3 class="Question">
Question3:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
<div id="s2q4 class="Question">
Question4:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
<div id="s2q5 class="Question">
Question5:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
<div id="s3q1 class="Question">
Question1set3:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
<div id="s3q2 class="Question">
Question2:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
<div id="s3q3 class="Question">
Question3:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
<div id="s3q4 class="Question">
Question4:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
<div id="s3q5 class="Question">
Question5:<BR> <textarea cols="40" rows="5" name="myname">
</textarea><BR>
</div>
-->
</form>
</td>
</div>
</body>
</html>
</body>