Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

count naming problems

Status
Not open for further replies.

jordan11

Technical User
May 24, 2003
150
GB
Hi,
I want to do a count but the name of the input box has to names how do I put this name into the request.form. I put ??? were I am having the problems.

response.Write "<input type=checkbox name=" & Strtype & "." & strquest & " value="&Strvalue& "> " & oRSc("Selection") & "<br>"
aSelected = split(request.form(????),",")
total = 0
for i = 0 to ubound(aSelected)
response.write(aSelected(i))
if IsNumeric(aSelected(i)) then
total = total + CDbl(aSelected(i))
end if

Thanks JJ
 
didnt quite understand...

did you mean to use:

formitem=&Strtype& "." &strquest&

request.form("formitem")

-DNG
 
yes that is what I mean.
Thanks I will give that go.
 
I get a syntax error when I use

formitem = &Strtype& "." &strquest&
 
yes that is what I done and it was ok, you got there before me.
thanks
 
I do not get a syntax error but when but it is not putting any values into the counter, When I do a response.write I get 0. when I rename the input checkbox to a single name like check it the works but the other problem I am getting is if the values are 1,2,3 it will give 6 plus when 1,2,3 . Although it works one ther is one name i need to use 2 names.

Thanks for you quick reply
JJ
 
are you passing the variables Strtype and strquest to the form processing page??

because i think these variables are available to you on the form page and you used them to name your check box...but when you post the form to the other page(form processing page) you also need to send these values to get hold of the check box name...did that make sense??

or am i missing something here?

-DNG
 
No basically I have a dynamic questionare that has checked boxes, radio buttons and select boxes. So to make them unique when I update I have strtype which will tell you whether it is a checkbox etc etc and questionid I need these values when I update to my database. The thing I need to do is be able to get the total value for all the checkboxs for each question before update.


Thanks again
 
Does anyone know how to reset a counter as I will like a total for each question but at the moment i get a total for all questions checked.


Thanks in advance
 
you need to do something like this:
Code:
for question = 1  to lastquestion
for i = 0 to ubound(aSelected)
response.write(aSelected(i))
if IsNumeric(aSelected(i)) then
total = total + CDbl(aSelected(i)) 
totalforquestion1=total
end if 
next
total=0 'reset total for next question
next

the above is just a pseudo code...

-DNG
 
I tried it but not sure were I am goibng wrong as all my results default to 0.

for question = 1 to lastquestion

how will I subsitute strquest for that where
strquest = oRSc("QuestionId")

Thanks so much for your help
 
how about something like this:
Code:
while not ORSc.EOF
strquest = oRSc("QuestionId") 
response.Write "<input type=checkbox name=" &  Strtype & "." & strquest & " value="&Strvalue& "> " & oRSc("Selection") &   "<br>"
aSelected = split(request.form(????),",")
total = 0
for i = 0 to ubound(aSelected)
response.write(aSelected(i))
if IsNumeric(aSelected(i)) then
total = total + CDbl(aSelected(i)) 
Response.Write total 'this will the total for each question
end if 
next
total=0 'reset the total for the next question
ORSc.MoveNext
wend

-DNG


 
I will try that but I do not think it will work as this is how my form looks.

Do while not oRScp.EOF
StrQuestID = oRScp("QuestionId")
StrType = oRScp("QType")
StrQuestion = oRScp("Question")
Response.Write "<tr><td width=755 valign=top colspan=3><strong>"&StrQuestion&"</strong></td></tr>"
txtSQL = "Select * from Selection where QuestionId =" & StrQuestID & ";"
'response.Write "<input type=hidden name=StrQuestID value="&StrQuestID&">"


Set oRSc=conn.Execute(txtSQL)
Errhandlerr Conn
Response.Write "<td>"

IF Strtype = 1 then

Do while not oRSc.EOF
Strvalue = oRSc("value")
strquest = oRSc("QuestionId")
strchecked = oRSc("value")& "." &oRSc("QuestionId")
'response.Write "<input type=hidden name=check value="&Strvalue&">"

response.Write "<input type=checkbox name=check value="& StrQuest & "/" &Strvalue& "> " & oRSc("Selection") & "<br>"
oRSc.Movenext
loop

elseif Strtype = 2 then
Response.Write"<table border=0 width=470 valign=top><tr><td align=right>&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;3 &nbsp;&nbsp;&nbsp;4&nbsp;&nbsp;&nbsp;&nbsp;5&nbsp;<br></td></tr></table>"

Do while not oRSc.EOF
oRSc.movefirst
response.Write"<table border=0 width=470 valign=top colspan=2><tr><td valign=top>"
Response.Write oRSc("Selection") &"</td><td align=right>"
For scorecounter = 1 to 5
Strvalue = CStr(scorecounter)
Response.Write "<input type='radio' name='"& Strtype & "." & oRSc("questionid") & "' value='" & Strvalue &"'>"

Next

Response.Write"</td></tr></table>"
oRSc.Movenext
loop
elseif Strtype = 3 then

Response.Write "<Select name="& Strtype & "." & oRSc("QuestionId") & ">"
Response.Write "<option value=></option>"
Do while not oRSc.EOF
Strvalue = oRSc("value")
Response.Write "<OPTION value=" &Strvalue& ">"
Response.Write oRSc("Selection") & "</Option><br>"
oRSc.MoveNext
loop
Response.Write "</select>"

End If
oRSc.Close
Set oRSc= nothing
Response.Write "</td></tr><tr><td>&nbsp;</td></tr>"
oRScp.Movenext
Loop
oRScp.Close
Set oRScp= nothing
%>
<tr>
<td align="center"><input type="submit" name="Submit" value="Next">&nbsp;&nbsp;&nbsp;<input type="button" value="Back" onClick="history.back()"></td>
</tr>
</form>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top