Forums

This topic is locked

Sum query in .asp page

Posted 22 May 2006 19:10:42
1
has voted
22 May 2006 19:10:42 John Schmidt posted:
Hello all,

What I want to do is have some code sum the answers each person gives (ten questions with answers 1 to 5) to give me a total score for each person (possible range of 10 to 50). I then want to have that score entered in a field in the same table (lotadata). I already have a score.asp page and can load whatever is in the 'score' field onto the page using a recordset query.

I was wondering if it would be possible to do this within the dreamweaver code and just keep the score variable (sum of all the answers) as a hidden field and then pass it to the next page when the submit button is clicked. Once the page is loaded, I can show the hidden field in a dynamic text box. My problem is getting the sum of scores.

Thanks again, and I hope I have explained this clearly.

Here is a section of the code I am working with. My changes are noted below:

MM_editConnection = MM_ConnectOpt_STRING
MM_editTable = "LOTADATA"
MM_editRedirectUrl = "/lot_finish.asp"
MM_fieldsStr =
"LOTA1|value|LOTA2|value|LOTA3|value|LOTA4|value|LOTA5|value|LOTA6|value|LOT
A7|value|LOTA8|value|LOTA9|value|LOTA10|value|Prior|value|Score|value"
MM_columnsStr = "LOTA1|none,none,NULL|LOTA2|none,none,NULL|LOTA3|none,none,NULL|LOTA4|none,n one,NULL|LOTA5|none,none,NULL|LOTA6|none,none,NULL|LOTA7|none,none,NULL|LOTA
8|none,none,NULL|LOTA9|none,none,NULL|LOTA10|none,none,NULL|Prior|none,none,
NULL|Score|none,none,NULL"

'MY CHANGES BEGIN HERE
'Need to sum these four checked-values from radio-fields
i_score = LOTA1.value + LOTA2.value + LOTA3.value + LOTA4.value
'Enter sum into hidden-field on form
Score = i_score
'END OF CHANGES

' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|"
MM_columns = Split(MM_columnsStr, "|"

' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next

Reply to this topic