Click to See Complete Forum and Search --> : getting sbmit button to not lose the query string in the URL


TonyLoco23
06-01-2009, 11:50 AM
I have a dynamic asp webpage to display a simple quiz.

The quiz that is displayed on the page can vary, and depends on a variable that is passed into the URL. The variable is QuizID:

i.e.

"www.myWebsite.com/quizPage.asp?QuizID=2"

On the bottum of the webpage there is a submit button called "Submit Answers".

For some reason when the user submits the answers by pressing on this button, the QuizID is lost. Even though the form action specificies the quizID for the refresh

i.e.

"<form action="QuizPage.asp?QuizID=<%=QuizID%>" method="get" name="formQuiz">"

I can see that when the page refreshes after the submit button is pressed, the webpage URL no longer has the QuizID value.

I tried with both method="post" and method="get" but neither work.

How can I get the page to remember the quizID, one ugly way would be to store the QuizID in a hidden textbox or in a session variable, but there must be a simpler, cleaner way???

Below is the code stripped down to its simplest form:

<%
dim QuizID

quizID = request.querystring("QuizID")


%>
<form action="QuizPage.asp?QuizID=<%=QuizID%>" method="get" name="formQuiz">

'(LONG CODE THAT PULLS THE QUIZ FROM A DATABASE AND DISPLAYS IT HERE HAS BEEN OMMITTED)

<input name="SubmitQuiz" type="submit" id="SubmitQuiz" value="Submit Answers"/>

</form>

gil davis
06-02-2009, 07:05 AM
Use a hidden input field rather than trying to use the ACTION of the FORM.

TonyLoco23
06-02-2009, 08:37 AM
Thanks Gil. That is what I have now done. Normally I do not like to use those kind of "work around" solutions. But now that I am pretty certain that this is the best way to do it I do not feel so bad.