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

multiple choice quiz

Status
Not open for further replies.

mycophobiac

Programmer
May 18, 2003
6
US
I'm creating a multiple choice quiz on a webpage, and I want to be able to have the user submit their answers. Ideally, clicking a button would send their answers to the next page, which would then check them for accuracy.

I need a way of sending variables or form data to another webpage, where a score can be totaled.

Is this possible with Javascript?

Thanks!
 
You could run it through a cookie, or the file.html?query_string, dunno if JS can pick up the post data :/

Ultimately the most robust solution is to have the server recieve the data and paste it into the response web page from which is can recieved again later.

----------
I'm willing to trade custom scripts for... [see profile]
 
I was hoping to have Javascript handle variables in the "file.html?query_string" technique that you mentioned. An advantage there would be being able to use the traditional HTML method of submitting data.
 
one method to get the query string is:

var a = document.location.href.split('?')[1];

That's normally fine but messes up if there are multiple ? but that probably won't matter because you're in control.

I think, but do not know, there is another method specifically intended for the purpose.

You can also use document.referrer to make sure someone didn't follow a link and get a half-finished questionaire.

Hope this is helpful to you.

----------
I'm willing to trade custom scripts for... [see profile]
 
These are the other solutions I thought existed.

search, hash, host, hostname, href, pathname, port, protocol

document.location.search should do the same thing as document.location.href.split('?')[1] but I didn't test.

----------
I'm willing to trade custom scripts for... [see profile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top