Checkbox Validation on Dynamic ASP Checkboxes

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
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();
}
 
B

Ben Amada

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)

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.

Hi. Here's a pretty decent approach:

1. Assign each checkbox a unique ID using sequential numbers (chk1, chk2 ...
chk7). In your ASP code, you can do this by creating an integer variable
you increment by 1 each time you output a checkbox control.

2. Store the largest sequential number in a hidden field (for example, 7).

3. In validation routine, use a "for" loop -- looping from 1 thru 7 --
checking the status of each checkbox.

Ben
 
C

clinttoris

Ben said:
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)

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.

Hi. Here's a pretty decent approach:

1. Assign each checkbox a unique ID using sequential numbers (chk1, chk2 ...
chk7). In your ASP code, you can do this by creating an integer variable
you increment by 1 each time you output a checkbox control.

2. Store the largest sequential number in a hidden field (for example, 7).

3. In validation routine, use a "for" loop -- looping from 1 thru 7 --
checking the status of each checkbox.

Ben

Hi Ben,

I'm going to have to say I don't understand. I do not wish to change
the structure since everything is working fine up until this point.
Could you clarify your point with some code. Sorry.
 
B

Ben Amada

Hi Ben,

I'm going to have to say I don't understand. I do not wish to change
the structure since everything is working fine up until this point.
Could you clarify your point with some code. Sorry.

The code below is untested, but should get you close to what you're looking
for with few changes to what you've already got:

=== ASP code ===

Dim iCheckboxID As Integer
iCheckboxID = 0

While Not objRS.EOF

iCheckboxID = iCheckboxID + 1

response.write "<input type=""checkbox"" id=""" & _
"chk" & iCheckboxID & """ Name=""Question" & _
objRS("Question_ID") & """ Value=""" & _
objTxt("Sub_Text") & """>" & _
objTxt("Text") & "<br>" & chr(13)

objRS.MoveNext

End While

response.write "<input type=""hidden"" " & _
"id=""CheckboxCount"" " & _
"value=""" & iCheckboxID & """>"

=== JavaScript code ===

function validateCheckBoxes(){
var bFlag = false;
var iCheckboxCount = document.getElementById('CheckboxCount').value;
for (var i=1; i <= iCheckboxCount; i++) {
if (document.getElementById("chk" + i).checked) {
bFlag = true;
}
}
if (!bFlag) {
alert("you haven't checked anything");
return false;
} else {
var oForm = document.SurveySubmitted;//change to real name
oForm.submit();
}
}
 
C

clinttoris

Thanks for accomodating Ben,

I have implemented the code without errors but it is not doing
anything. Here is my HTM source code and it looks fine.

<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" id="chk1" Name="Question1" Value="a">Dispatch
Newsletter<br>
<input type="checkbox" id="chk1" Name="Question1" Value="b">General
Notifications(email)<br>
<input type="checkbox" id="chk1" Name="Question1" Value="c">Intranet
Homepage (InSite)<br>
<input type="checkbox" id="chk1" Name="Question1" Value="d">IT Service
Desk Corporate Notifications<br>
<input type="checkbox" id="chk1" Name="Question1" Value="e">Team
Websites (http://go/it, http://go/cso etc.)<br>
<BR>Other<BR><textarea name="textBoxAnswer1" rows="2"
cols="50"></textarea>
<input type="hidden" name="HiddenTextValue" value="f">
<input type="hidden" id="CheckboxCount" value="1"><p><b>2. Please
select the 3 most helpful means of communication?</b><p>
<input type="checkbox" id="chk2" Name="Question2" Value="a">Online
Newsletter<br>
<input type="checkbox" id="chk2" Name="Question2" Value="b">Print
Newsletter<br>
<input type="checkbox" id="chk2" Name="Question2" Value="c">Intranet
homepage (Insite)<br>
<input type="hidden" id="CheckboxCount" value="2"><p><b>3. Please
select the three least helpful means of communication</b><p>
<input type="hidden" id="CheckboxCount" value="2"><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>
<input type="hidden" id="CheckboxCount" value="2"><p>
<hr>
</TABLE>
<TABLE>
<TR>
<TD COLSPAN=3 ALIGN="center"><BR>
<input type=submit value="Submit" ONCLICK="validateCheckBoxes();">

</TD>
</TR>
</TABLE>
</FORM>
</CENTER>
 
C

clinttoris

Thanks for accomodating Ben,

I have implemented the code without errors but it is not doing
anything. Here is my HTM source code and it looks fine.

<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" id="chk1" Name="Question1" Value="a">Dispatch
Newsletter<br>
<input type="checkbox" id="chk1" Name="Question1" Value="b">General
Notifications(email)<br>
<input type="checkbox" id="chk1" Name="Question1" Value="c">Intranet
Homepage (InSite)<br>
<input type="checkbox" id="chk1" Name="Question1" Value="d">IT Service
Desk Corporate Notifications<br>
<input type="checkbox" id="chk1" Name="Question1" Value="e">Team
Websites (http://go/it, http://go/cso etc.)<br>
<BR>Other<BR><textarea name="textBoxAnswer1" rows="2"
cols="50"></textarea>
<input type="hidden" name="HiddenTextValue" value="f">
<input type="hidden" id="CheckboxCount" value="1"><p><b>2. Please
select the 3 most helpful means of communication?</b><p>
<input type="checkbox" id="chk2" Name="Question2" Value="a">Online
Newsletter<br>
<input type="checkbox" id="chk2" Name="Question2" Value="b">Print
Newsletter<br>
<input type="checkbox" id="chk2" Name="Question2" Value="c">Intranet
homepage (Insite)<br>
<input type="hidden" id="CheckboxCount" value="2"><p><b>3. Please
select the three least helpful means of communication</b><p>
<input type="hidden" id="CheckboxCount" value="2"><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>
<input type="hidden" id="CheckboxCount" value="2"><p>
<hr>
</TABLE>
<TABLE>
<TR>
<TD COLSPAN=3 ALIGN="center"><BR>
<input type=submit value="Submit" ONCLICK="validateCheckBoxes();">

</TD>
</TR>
</TABLE>
</FORM>
</CENTER>
 
B

Ben Amada

Thanks for accomodating Ben,

I have implemented the code without errors but it is not doing
anything. Here is my HTM source code and it looks fine.

Thanks for posting the outputted HTML. I now see a couple of problems ...

(1) Each checkbox should have a unique "id".

(2) However, there is another problem in that I initially didn't realize you
have different sets of questions where (I'm guessing) at least one box must
be checked for each set of questions.

(3) Each checkbox 'input' tag should have a closing tag -- </input>.

--- RECOMMENDATIONS ---

(1) Use the following checkbox "id" scheme:

- For question 1's checkbox IDs, use "chk1_1", "chk1_2", "chk1_3", etc.
- For question 2's checkbox IDs, use "chk2_1", "chk2_2", "chk2_3", etc.

(2) Create one hidden input field for each set of questions:

- For question 1, create hidden input field "cbCount1" with a value
containing the number of checkboxes under question 1.
- For question 2, create hidden input field "cbCount2" with a value
containing the number of checkboxes under question 2.
etc.

(3) Create one hidden input field (QuestionCount) which contains the number
of questions you have on the page.

---------
If you follow the above 3 recommendations, then the JavaScript below should
work to make sure at least one box has been checked for each set of
questions.

=== JavaScript code Below ===

function validateCheckBoxes(){

var bOK = true;
var bFlag = false;
var iCheckboxCount = 0;
var iQuestionCount = document.getElementById('QuestionCount').value;

for (var i=1; i <= iQuestionCount; i++) {
bFlag = false;
iCheckboxCount = document.getElementById('cbCount' + i).value;

for (var j=1; j <= iCheckboxCount; j++) {
if (document.getElementById("chk" + i + "_" + j).checked) {
bFlag = true;
}
}

if (!bFlag) { bOK = false; }
}

if (!bOK) {
alert("not all questions answered");
return false;
} else {
var oForm = document.SurveySubmitted;//change to real name
oForm.submit();
}

}
 
C

clinttoris

O.k Ben you know what I'm gonna ask you next right?
Well I'm not very good working with Dynamic data. Could you provide
some coe for the recommendation. Obviously that is not right of me to
ask but when I see something I understand it more thoroughly for the
next time. I'm not gonna lie I'm not sure how to complete what you
asked. Sure I understand the hidden field part but the rest not sure.
Anyway you can provide. Thanks again Ben.

And yes, each question should have at least one checkbox checked.
 
B

Ben Amada

Well I'm not very good working with Dynamic data. Could you provide
some coe for the recommendation. Obviously that is not right of me to
ask but when I see something I understand it more thoroughly for the
next time. I'm not gonna lie I'm not sure how to complete what you
asked. Sure I understand the hidden field part but the rest not sure.
Anyway you can provide. Thanks again Ben.

And yes, each question should have at least one checkbox checked.

I believe you're asking about the ASP coding. Basically you'll want to
maintain 2 variables, iQuestionID and iCheckboxID, where iQuestionID keeps
track of the current question id and iCheckboxID keeps track of the current
checkbox id WITHIN (or FOR) the current question. Not being familiar with
the details of your code, the sample code below is just an example of what
you are probably looking for.

Dim iQuestionID As Integer
Dim iCheckboxID As Integer
Dim strCurrentQuestionID As String

While Not objRS.EOF

If objRS("Question_ID") <> strCurrentQuestionID Then

If iQuestionID > 0 Then

response.write "<input type=""hidden"" " & _
"id=""cbCount""" & iQuestionID & " " & _
"value=""" & iCheckboxID & """>"

End If

strCurrentQuestionID = objRS("Question_ID")
iQuestionID = iQuestionID + 1
iCheckboxID = 0

response.write "Question #" & iQuestionID & "<br>"

End If

iCheckboxID = iCheckboxID + 1

response.write "<input type=""checkbox"" id=""" & _
"chk" & iQuestionID & "_" & iCheckboxID & """ " & _
"Name=""Question" & _
objRS("Question_ID") & """ Value=""" & _
objTxt("Sub_Text") & """>" & _
objTxt("Text") & "</input><br>" & chr(13)

objRS.MoveNext
End While

response.write "<input type=""hidden"" " & _
"id=""QuestionCount"" " & _
"value=""" & iQuestionID & """>"
 
B

Ben Amada

Ben said:
If iQuestionID > 0 Then

response.write "<input type=""hidden"" " & _
"id=""cbCount""" & iQuestionID & " " & _
"value=""" & iCheckboxID & """>"

End If

.... oops (minor mistake), the above code should read:

If iQuestionID > 0 Then

response.write "<input type=""hidden"" " & _
"id=""cbCount" & iQuestionID & """ " & _
"value=""" & iCheckboxID & """>"

End If
 
B

Ben Amada

.... one more glitch (obviously I've just been typing air-code :) You'll
want to output one last hidden input field after the While loop is over.

....
....
End While

If iQuestionID > 0 Then
response.write "<input type=""hidden"" " & _
"id=""cbCount" & iQuestionID & """ " & _
"value=""" & iCheckboxID & """>"
End If

response.write "<input type=""hidden"" " & _
"id=""QuestionCount"" " & _
"value=""" & iQuestionID & """>"
If iQuestionID > 0 Then
 
C

clinttoris

Wow Ben,

I would had to start changing code that I worked so hard on. What if I
wanted to implement your code to my code. This is my code. Short and
sweet. Could it not be incorporated into my code

<BODY leftmargin="0" rightmargin="0" marginwidth="0" topmargin="0"
marginheight="0" bottommargin="0" bgcolor="#ffffff">
<table width="60%" cellspacing="0" cellpadding="5">
<%
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "DSN"
'now find the quiz specified by the URL command line
'e.g. vbquiz.asp?quiz=1 means show quiz 1
survey=1
set objRS = oConn.Execute("SELECT * FROM Survey WHERE Survey_ID=" &
survey)
%>
<hr>
<font size=5>
<center><b><% =objRS("Descr") %></center></b>
<HR>
</font>
<p>
<form
action="testSubmission.asp?Survey=<%=request.querystring("Survey") %>"
method="post" name="SurveySubmitted">
<%
objRS.close
'now start the main loop to find all the questions

set objRS = oConn.Execute("SELECT * FROM survey_questions WHERE
Survey_ID=" & survey & " ORDER BY Question_ID")

If not objRS.eof Then
%>
<input type="hidden" name="HiddenSurveyID"
value="<%=objRS("Survey_ID")%>">
<input type="hidden" name="HiddenQuestionID"
value="<%=objRS("Question_ID")%>">
<%
End IF
if not objRS.EOF then
objRS.movefirst
do
response.write "<b>" & objRS("Question_ID") & ". " &
objRS("Question") & "</b><p>" & chr(13)
'now display the available options
set objTxt = oConn.Execute("SELECT * FROM survey_user_text WHERE
Question_ID=" & objRS("Question_ID") )
if not objTxt.EOF then
objTxt.movefirst
Do
If (objTxt("Type")) = "radio" then
response.write "<input type=checkbox Name=""Question" &
objRS("Question_ID") & """ Value=""" & objTxt("Sub_Text") & """>" &
objTxt("Text") & "<br>" & chr(13)
ELSE
response.write "<BR>" & objTxt("Text")& "<BR>" %><textarea
name="textBoxAnswer<%=objRS("Question_Id")%>" rows="2"
cols="50"></textarea>
<input type="hidden" name="HiddenTextValue"
value="<%=objTxt("sub_text")%>">
<%
End IF
objTxt.movenext
loop until objTxt.EOF
end if
response.write "<p>"
objRS.movenext
loop until objRS.EOF
end if
oConn.close
%>
<hr>
</TABLE>
<TABLE>
<TR>
<TD COLSPAN=3 ALIGN="center"><BR>
<input type=submit value="Submit" ONCLICK="validateCheckBoxes();">
</TD>
</TR>
</TABLE>
</FORM>
</CENTER>
 
B

Ben Amada

Wow Ben,

I would had to start changing code that I worked so hard on. What if I
wanted to implement your code to my code. This is my code. Short and
sweet. Could it not be incorporated into my code

Didn't mean to overwhelm you :) I was able to basically copy the ASP
code from my other post and paste it into your ASP code (see below).
It is untested as I don't have a database setup -- but should work.
The only other thing you'd want to do is insert the JavaScript I posted
a few posts ago into your code.

Good luck,
Ben
---------------------------------------------

<BODY leftmargin="0" rightmargin="0" marginwidth="0" topmargin="0"
marginheight="0" bottommargin="0" bgcolor="#ffffff">
<table width="60%" cellspacing="0" cellpadding="5">
<%
Dim iQuestionID As Integer
Dim iCheckboxID As Integer
Dim strCurrentQuestionID As String
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "DSN"
'now find the quiz specified by the URL command line
'e.g. vbquiz.asp?quiz=1 means show quiz 1
survey=1
set objRS = oConn.Execute("SELECT * FROM Survey WHERE Survey_ID=" &
survey)
%>
<hr>
<font size=5>
<center><b><% =objRS("Descr") %></center></b>
<HR>
</font>
<p>
<form
action="testSubmission.asp?Survey=<%=request.querystring("Survey") %>"
method="post" name="SurveySubmitted">
<%
objRS.close
'now start the main loop to find all the questions

set objRS = oConn.Execute("SELECT * FROM survey_questions WHERE
Survey_ID=" & survey & " ORDER BY Question_ID")

If not objRS.eof Then
%>
<input type="hidden" name="HiddenSurveyID"
value="<%=objRS("Survey_ID")%>">
<input type="hidden" name="HiddenQuestionID"
value="<%=objRS("Question_ID")%>">
<%
End IF
if not objRS.EOF then
objRS.movefirst
do
response.write "<b>" & objRS("Question_ID") & ". " &
objRS("Question") & "</b><p>" & chr(13)
'now display the available options
set objTxt = oConn.Execute("SELECT * FROM
survey_user_text WHERE
Question_ID=" & objRS("Question_ID") )
if not objTxt.EOF then

objTxt.movefirst
Do

If (objTxt("Type")) = "radio" then

If objRS("Question_ID") <> strCurrentQuestionID Then

If iQuestionID > 0 Then
response.write "<input type=""hidden"" " & _
"id=""cbCount" & iQuestionID & """ " & _
"value=""" & iCheckboxID & """>"
End If

strCurrentQuestionID = objRS("Question_ID")
iQuestionID = iQuestionID + 1
iCheckboxID = 0

'response.write "Question #" & iQuestionID & "<br>"

End If

iCheckboxID = iCheckboxID + 1

response.write "<input type=""checkbox"" id=""" & _
"chk" & iQuestionID & "_" & iCheckboxID & """ " & _
"Name=""Question" & _
objRS("Question_ID") & """ Value=""" & _
objTxt("Sub_Text") & """>" & _
objTxt("Text") & "</input><br>" & chr(13)

ELSE
response.write "<BR>" & objTxt("Text")& "<BR>" %><textarea
name="textBoxAnswer<%=objRS("Question_Id")%>" rows="2"
cols="50"></textarea>
<input type="hidden" name="HiddenTextValue"
value="<%=objTxt("sub_text")%>">
<%
End IF
objTxt.movenext
loop until objTxt.EOF

end if
response.write "<p>"
objRS.movenext
loop until objRS.EOF

If iQuestionID > 0 Then
response.write "<input type=""hidden"" " & _
"id=""cbCount" & iQuestionID & """ " & _
"value=""" & iCheckboxID & """>"
End If

response.write "<input type=""hidden"" " & _
"id=""QuestionCount"" " & _
"value=""" & iQuestionID & """>"

end if
oConn.close
%>
<hr>
</TABLE>
<TABLE>
<TR>
<TD COLSPAN=3 ALIGN="center"><BR>
<input type=submit value="Submit"
ONCLICK="validateCheckBoxes();">
</TD>
</TR>
</TABLE>
</FORM>
</CENTER>
 
C

clinttoris

Hello again Ben and I really appreciate this.
I am getting a Type Mismatch error with respect to this line

If objRS("Question_ID") <> strCurrentQuestionID Then

Also, I did not declare a type for the following variables since you do
not have to in asp and secondly it gives me an error. I think this is
the cause of the type mismatch. Any ideas?

Dim iQuestionID As Integer
Dim iCheckboxID As Integer
Dim strCurrentQuestionID As String
 
C

clinttoris

Hello again Ben and I really appreciate this.
I am getting a Type Mismatch error with respect to this line

If objRS("Question_ID") <> strCurrentQuestionID Then

Also, I did not declare a type for the following variables since you do
not have to in asp and secondly it gives me an error. I think this is
the cause of the type mismatch. Any ideas?

Dim iQuestionID As Integer
Dim iCheckboxID As Integer
Dim strCurrentQuestionID As String
 
N

news

Hello again Ben and I really appreciate this.
I am getting a Type Mismatch error with respect to this line

If objRS("Question_ID") <> strCurrentQuestionID Then

Also, I did not declare a type for the following variables since you do
not have to in asp and secondly it gives me an error. I think this is
the cause of the type mismatch. Any ideas?

Classic ASP uses VBscript, which doesn't declare variable types as you
noted, but it does have typed variables. Generally everything is of
type "variant" but often stuff coming back from a database has explicit
types set that give you typemismatch errors.

If the ID is an integer, then you'll need to convert it to a longint
first - clng(objRS("Question_ID")). However that will crash if for some
reason the Question ID is null, so check that first.


Never, ever, ever, ever do this.

You are outputting the querystring straight back to the client. This
lets someone insert any code they like into your page. Always read
querystring parameters into a local variable, check its content and the
write that back to the client. If you are expecting an integer, check
that it is one and is in range, otherwise produce an error or use a
default value.
 
C

clinttoris

O.k.

Well I added what you said Ben and still no good. The value being
returned is a number. Question_id is the question Number. So I added
If CLng(objRS("Question_ID") <> strCurrentQuestionID Then

and still getting the errors. I also remarked the line completely just
to troubleshoot and see what is going on and the page came up. However
if I click submit i get
a non-numeric character was found where a numeric was expected
/itsurvey/testSubmission.asp, line 64
 
B

Ben Amada

Hello again Ben and I really appreciate this.
I am getting a Type Mismatch error with respect to this line

If objRS("Question_ID") <> strCurrentQuestionID Then

Also, I did not declare a type for the following variables since you do
not have to in asp and secondly it gives me an error. I think this is
the cause of the type mismatch. Any ideas?

Dim iQuestionID As Integer
Dim iCheckboxID As Integer
Dim strCurrentQuestionID As String

Okay ... I would drop the 'type' of the variables and give each variable a
default value. So replace the 3 variable declaration lines above with:

Dim iQuestionID
Dim iCheckboxID
Dim strCurrentQuestionID
iQuestionID = 0
iCheckboxID = 0
strCurrentQuestionID = 0

This assumes objRS("Question_ID") is a numeric value.

Ben
 
C

clinttoris

Nope still no go.

Here is my table structure

"Column Name""Data Type""
"SURVEY_ID""NUMBER"
"QUESTION_ID""NUMBER"
"QUESTION""VARCHAR2(4000 Bytes)"
"TYPE" "VARCHAR2(4000 Bytes)" ""
 
B

Ben Amada

Nope still no go.

Here is my table structure

"Column Name""Data Type""
"SURVEY_ID""NUMBER"
"QUESTION_ID""NUMBER"
"QUESTION""VARCHAR2(4000 Bytes)"
"TYPE" "VARCHAR2(4000 Bytes)" ""

Hmm... what error are you getting now? By the way, since
strCurrentQuestionID is now initialized with a numeric value, you should be
able to use the following line of code:

If objRS("Question_ID") <> strCurrentQuestionID Then

So you don't need the CLng() function since both objRS("Question_ID") and
strCurrentQuestionID are numeric.

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top