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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditionally insert value into db

Status
Not open for further replies.

nat35

Programmer
Nov 10, 2002
86
0
0
AU
Hi everyone,my question is..is this possible using a form conditionally insert question num into db.
if the user hit submit1 the value will be 1 and so on.

I have also code to check the correct answer
<%
If Request.Form("Submit1") = "Submit" Then

If Request.Form("RadioGroup1") = "b" Then
Msg1 = "Correct "
Else
Msg1 = "Incorrect.Try again "
End If

End If
%>
<%
If Request.Form("Submit2") = "Submit" Then

If Request.Form("RadioGroup2") = "c" Then
Msg2 = "Correct "
Else
Msg2 = "Incorrect.Try again "
End If

End If
%>
Logically I understand but how to write code I don't know
Here is my form
Questions:
1. If the site is not level what steps are taken to correct?
o Nothing
o Cut and Fill as necessary
o Build -up brick work
Submit1

2. On the site plan what do the initials "dp" stand for?
o Data point
o Deep pit
o Down-pipe
Submit2

Thank you very much for that
Nat







 
depends on the flow of questionare and what exaclty ur trying to record....but ur on the right track
u could:
use JS 'onClick' or 'onSUbmit'
or
make hidden fields along with each question (submitt button) group in whihc u can have a defalut value and then simply insert that field
or
u can have 1 single hidden field whose value would be set depending on which "Submit" was clicked
I dont quite follow what is the reason to recording what button they clicked....to see how many times they tried to "answer" the question before they got it right or...???
Anyhow,d o you have an URL so we can visulaise
Post some more, this should not be too hard to code as long as we can layout the logic behing it!
All the best

:--------------------------------------------------------------------------:
fugitive.gif

ok,ok...I did shoot the deputy but he told me he was the sheriff!
:--------------------------------------------------------------------------:
 
thank you for replay
Unfortually I cannot give you url as this is our Intranet site.
you were absolutly right the reason to recording what button they clicked....to see how many times they tried to "answer" the question before they got it right
We are trying to work out how many times the employee clicks on the wrong answer and get the report out show us these figures so we can orrange for the staff to do more training in their areas.
I have done hidden fields as l_name,f_name,attempt_no and set the default value
I don't know how to write the code for hidden field q_no
where value ( 1 or 2)needs to be set depending on which "submit" was clicked
thank you nat
 
hey nat!
did u get this resolved?
take a look at:
for increments and some questionare like forms on:


In general:
I would suggest u use the client side scripts and then ASP-SQL to just insert the values into your DB from your hidden fields....

so, make your radio group along with corresponding hidden field whose value u will set in manner:

1. IF any radio button is checked from the group
--------(something was selected so we can start)

2. If document.form.radio.checked =! "c" THEN
--------(if the answer is not equal to the right one)

ALERT("wrong answer") AND
INCREMENT hidden field value

--------(use the concept from the linke above to increment value of the hidden field)
End If
ELSE (no button was checked to begin with)
ALERT ("please select at least one answer")
END IF


this way u will end up for as many hidden fields as questions....and only 1 form with true submit...basically putting u in postion to just use SQL to insert a few fields into DB with one action.

Sorry for not posting the code but my JS skills are rusty....and never that good to begin with :).
Perhaps u can take this logic to JavaScript or VBSciprt forum...where they can help you out with arrays and loops so you dont have massive code for each radio group.
At all costs avaid doing a client-server trip for these increments per question...server sould only accpet the values from hiddend fields ones te whole page is finsihed...use your resources
All the best!


:--------------------------------------------------------------------------:
fugitive.gif

ok,ok...I did shoot the deputy but he told me he was the sheriff!
:--------------------------------------------------------------------------:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top