Hello Experts,
I have been told to post this in the Javascript forum as I want to do
this client side just before my form gets submitted. Once the user
clicks the submit button a javascript function needs to run and
validate all the checkboxes on my form and make sure none of them are
unchecked. I suck at Javascript and my problem is 2fold. I have the
following code that constructs the checkbox
Better yet here is my source code just in case you need it
[code]
<form action="testSub mission.asp?Sur vey=" method="post"
name="SurveySub mitted">
<input type="hidden" name="HiddenSur veyID" value="1">
<input type="hidden" name="HiddenQue stionID" value="1">
<b>1. Which of the following RIM Communication vehicles do you read
regularly? Please mark all that apply.</b><p>
<input type=checkbox Name="Question1 " Value="a">Dispa tch Newsletter<br>
<input type=checkbox Name="Question1 " Value="b">Gener al
Notifications(e mail)<br>
<input type=checkbox Name="Question1 " Value="c">Intra net Homepage
(InSite)<br>
<input type=checkbox Name="Question1 " Value="d">IT Service Desk
Corporate Notifications<b r>
<input type=checkbox Name="Question1 " Value="e">Team Websites
(http://go/it, http://go/cso etc.)<br>
<BR>Other<BR><t extarea name="textBoxAn swer1" ></textarea>
<input type="hidden" name="HiddenTex tValue" value="f">
<p><b>2. Please select the 3 most helpful means of
communication?</b><p>
<input type=checkbox Name="Question2 " Value="a">Onlin e Newsletter<br>
<input type=checkbox Name="Question2 " Value="b">Print Newsletter<br>
<input type=checkbox Name="Question2 " Value="c">Intra net homepage
(Insite)<br>
<p><b>3. Please select the three least helpful means of
communication</b><p>
<p><b>5. To ensure you stay well informed about IT services, projects
and updates, what communication vehicle would you read? Please select
one</b><p>
<p>
<hr>
</TABLE>
<TABLE>
<TR>
<TD COLSPAN=3 ALIGN="center"> <BR>
<input type=submit value="Submit" ONCLICK="javasc ript function;">
</TD>
</TR>
</TABLE>
[code]
With this code I need to create a javascript function and all the code
that I found refers to the check box name in the code. I however, have
no idea how to refer to my checkbox name because it is created from
database columns as shown in the above code right before the HTML
source code. Your help is greatly appreciated.
Here is the code I found but please if you have something better then
this please help. Thanks again
I have been told to post this in the Javascript forum as I want to do
this client side just before my form gets submitted. Once the user
clicks the submit button a javascript function needs to run and
validate all the checkboxes on my form and make sure none of them are
unchecked. I suck at Javascript and my problem is 2fold. I have the
following code that constructs the checkbox
Code:
response.write "<input type=checkbox Name=""Question" &
objRS("Question_ID") & """ Value=""" & objTxt("Sub_Text") & """>" &
objTxt("Text") & "<br>" & chr(13)
[code]
<form action="testSub mission.asp?Sur vey=" method="post"
name="SurveySub mitted">
<input type="hidden" name="HiddenSur veyID" value="1">
<input type="hidden" name="HiddenQue stionID" value="1">
<b>1. Which of the following RIM Communication vehicles do you read
regularly? Please mark all that apply.</b><p>
<input type=checkbox Name="Question1 " Value="a">Dispa tch Newsletter<br>
<input type=checkbox Name="Question1 " Value="b">Gener al
Notifications(e mail)<br>
<input type=checkbox Name="Question1 " Value="c">Intra net Homepage
(InSite)<br>
<input type=checkbox Name="Question1 " Value="d">IT Service Desk
Corporate Notifications<b r>
<input type=checkbox Name="Question1 " Value="e">Team Websites
(http://go/it, http://go/cso etc.)<br>
<BR>Other<BR><t extarea name="textBoxAn swer1" ></textarea>
<input type="hidden" name="HiddenTex tValue" value="f">
<p><b>2. Please select the 3 most helpful means of
communication?</b><p>
<input type=checkbox Name="Question2 " Value="a">Onlin e Newsletter<br>
<input type=checkbox Name="Question2 " Value="b">Print Newsletter<br>
<input type=checkbox Name="Question2 " Value="c">Intra net homepage
(Insite)<br>
<p><b>3. Please select the three least helpful means of
communication</b><p>
<p><b>5. To ensure you stay well informed about IT services, projects
and updates, what communication vehicle would you read? Please select
one</b><p>
<p>
<hr>
</TABLE>
<TABLE>
<TR>
<TD COLSPAN=3 ALIGN="center"> <BR>
<input type=submit value="Submit" ONCLICK="javasc ript function;">
</TD>
</TR>
</TABLE>
[code]
With this code I need to create a javascript function and all the code
that I found refers to the check box name in the code. I however, have
no idea how to refer to my checkbox name because it is created from
database columns as shown in the above code right before the HTML
source code. Your help is greatly appreciated.
Here is the code I found but please if you have something better then
this please help. Thanks again
Code:
function validateCheckBoxes(){
var oForm = document.SurveySubmitted;//change to real name
var oCheck = oForm.HiddenTextValue;//change to real name
var flag = false;
var i;
if(!oCheck.length&&oCheck.checked)flag = true;
else{for(i=0;i<oCheck.length;i++)if(oCheck[i].checked)flag=true;}
if(!flag){alert("you haven't checked anything");return false;}
else oForm.submit();
}
Comment