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

Updating a sql database 2

Status
Not open for further replies.

JonathanG6SWJ

Programmer
Joined
Jan 18, 2005
Messages
39
Location
GB
I have an asp page that presents the user with 65 questions. I am using database paging to present 8 records (questions) per page. The question text is sourced from a mysql db. The user responds by selecting one of a group of 7 radio buttons per question. This all works fine. My question is how to update a results table in a mysql database with the value of the radio button. I guess I need to update the database with the 8 questions responded to by the user page by page ie 8 records at a time.
I have two buttons "Prev" & "Next" which currently are submit buttons.

How do I use these triggers to call db update routine?
Do I use onClick property?
Do I use asp or javascript or vbscript?
How can I stop the user (or safely trap) from using browser "back" or "forward"?

Sorry - lots of questions but my learning curve is currently vertical!!

Hope the above makes sense!
Many thanks in advance.
Jonathan
 
For something like this, I would have my answers table set to "-1" for each answer and then update it when then user calls the next page. For the update, I would make sure that the current answer is still "-1" before I updated...

Code:
"UPDATE answers SET answerVal = '" & request("radioName") & "' WHERE user = " & userID & " AND question = " &  questionNumber & " AND [blue]answerVal = -1[/blue]"

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
zen.gif

 
Don't bother trying to control the user clicking the BACK button... just make it so that the answers can only be submitted once. I think maybe I just said the same thing as mwolf00.
 
mwolf00 - thanks for code example...
Sheco
Thanks for info. However unfortuantley I need to allow the user to edit the records if they have made a mistake or changed their mind so they have to be submitted more than once - any suggestions to controlling back browser scenario?

 
Well you can pop up a separate browser with no control buttons and then trap the right-click.

That would be pretty good as long as everyone was using IE and nobody was purposely trying to go back.

If you can't count on "fiendly" users... if they may not all always have the same browser... if there is anything to gain by going back... someone will.

For example, if this is a test where students have incentive to cheat by going back ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top