...

View Full Version : Help with Survey - Using Checkboxes and JavaScript



affu2000
04-27-2006, 04:25 PM
Hello,

I am trying to create a survey. I have five categories and each has 6 or more questions (answers as scale 1-10) in it.

Eg. Finance, Economy, Private Sector, Technology.

Finance:
Q1: blah blah blah?
Radio Buttons: 1 - 10

Q2: blah blah blah?
Radio Buttons: 1 - 10

I want the user to select the categories they want to be surveyed in by providing a check box beside each category. The user can select one or more categories.

When the user checks the categories and click Submit or OK, on the next page, it should display only those categories that the user selected with their respective questions.

How do I achieve this? Please help me.

Thanks in advance.

Newbie

Affu Q

Kor
04-27-2006, 04:42 PM
You may set all the radios as disabled by default, and enable only the groups related to the check boxes. Disabled elements do not send their values onsubmit. To give you an example I must know how your elements are HTML grouped, show us one or two of your groups check-box/radios. I mean the way you want to code them HTML

affu2000
04-27-2006, 10:53 PM
Thanks for the reply. Here is the code that I think want to use.

I would like the user to select one or more sector, click Go and then should be able to see questions from the selected sector on th next page.

I also need help with what I need to put in the action for the form that I am using (please see code.)

Thanks for your help. :)

Affu Q


<body>
<p>&nbsp</p>
<p>Welcome User,</p>

<form name="Sector" method="POST" action="I also need help with this??">
<!--I need to know what to put in the action. All I want is to remember the selection from the user to display the questions on the next page-->
<div><span class="clsSearchSteps">1.&nbsp</span><span class="sectionHeadBlack">&nbsp;<b>Please select the sector:</b></span>
<br><br>
<div class="ColorBar" align="center">
<table cellspacing="0" cellpadding="3" border="1" width="75%">
<tr>
<td><input type="Checkbox" name="c1" value="0" title="Economics">Economics<br></td>
<td><input type="Checkbox" name="c1" value="1" title="Finance">Finance<br></td>
<td><input type="Checkbox" name="c1" value="2" title="Private Sector">Private Sector<br></td>
<td><input type="Checkbox" name="c1" value="3" title="Social">Social<br></td>
</tr>
</table>
</div>

<p><input type="submit" value="Go" name="B1"></p>
</form>






You may set all the radios as disabled by default, and enable only the groups related to the check boxes. Disabled elements do not send their values onsubmit. To give you an example I must know how your elements are HTML grouped, show us one or two of your groups check-box/radios. I mean the way you want to code them HTML

Kor
04-28-2006, 09:23 AM
All I want is to remember the selection from the user to display the questions on the next page

In this case you must use a server-side aplication, not javascript (which is a client-side).

affu2000
04-29-2006, 02:19 PM
Hello,

If I just want to use JavaScript, how would I do it?

Thanks

Affu Q

vwphillips
04-29-2006, 02:41 PM
you could use a cookie

http://www.vicsjavascripts.org.uk/FormCompendium/FormCompendium.htm

script f19

affu2000
04-30-2006, 03:39 PM
Hello Vic,

Could you please give me an example with one of the categories that I specified in the code above.

Thanks in advance

Affu Q :confused:



you could use a cookie

http://www.vicsjavascripts.org.uk/FormCompendium/FormCompendium.htm

script f19

vwphillips
04-30-2006, 04:21 PM
<body onload="f19_GetFormCookie();" >
<form title="f19_Include" onclick="f19_SetFormCookie();">
<INPUT name="Q1" type="radio" >
<INPUT name="Q1" type="radio" >
<INPUT name="Q1" type="radio" >
<INPUT name="Q1" type="radio" ><br>
<INPUT name="Q2" type="radio" >
<INPUT name="Q2" type="radio" >
<INPUT name="Q2" type="radio" >
<INPUT name="Q2" type="radio" >
</form>




<body onload="f19_GetFormCookie();zxcFind();" >
<div id="fred" >
<div style="display:none;width:200px;height:50px;background-color:#FFFFCC;" >O1 A1</div>
<div style="display:none;width:200px;height:50px;background-color:#FFFFCC;" >O1 A2</div>
<div style="display:none;width:200px;height:50px;background-color:#FFFFCC;" >O1 A3</div>
<div style="display:none;width:200px;height:50px;background-color:#FFFFCC;" >O1 A4</div>
<div style="display:none;width:200px;height:50px;background-color:#FFFFCC;" >O2 A1</div>
<div style="display:none;width:200px;height:50px;background-color:#FFFFCC;" >O2 A2</div>
<div style="display:none;width:200px;height:50px;background-color:#FFFFCC;" >O2 A3</div>
<div style="display:none;width:200px;height:50px;background-color:#FFFFCC;" >O2 A4</div>
</div>

<script language="JavaScript" type="text/javascript">
<!--

function zxcFind(){
var pobj=document.getElementById('fred');
var ds=pobj.getElementsByTagName('DIV');
var conds=f19_GetCookie(f19_Cookie+'RC').split('~^~');
for (var zxc0=0;zxc0<ds.length;zxc0++){
if (conds[zxc0]=='true'){
ds[zxc0].style.display='';
}
}
}

//-->
</script>


+ the f19 code on each page

affu2000
04-30-2006, 09:32 PM
Thank you so much Vic. I will give this a try.

I will let you know if I get stuck somewhere.

Thanks again :thumbsup:

Affu Q



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum