C
clinttoris
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
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)
Better yet here is my source code just in case you need it
Code:
<form action="testSubmission.asp?Survey=" method="post"
name="SurveySubmitted">
<input type="hidden" name="HiddenSurveyID" value="1">
<input type="hidden" name="HiddenQuestionID" 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">Dispatch Newsletter<br>
<input type=checkbox Name="Question1" Value="b">General
Notifications(email)<br>
<input type=checkbox Name="Question1" Value="c">Intranet Homepage
(InSite)<br>
<input type=checkbox Name="Question1" Value="d">IT Service Desk
Corporate Notifications<br>
<input type=checkbox Name="Question1" Value="e">Team Websites
(http://go/it, http://go/cso etc.)<br>
<BR>Other<BR><textarea name="textBoxAnswer1" ></textarea>
<input type="hidden" name="HiddenTextValue" value="f">
<p><b>2. Please select the 3 most helpful means of
communication?</b><p>
<input type=checkbox Name="Question2" Value="a">Online Newsletter<br>
<input type=checkbox Name="Question2" Value="b">Print Newsletter<br>
<input type=checkbox Name="Question2" Value="c">Intranet 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="javascript 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();
}