Jump to content

A simple idea that needs a script


coleby58

Recommended Posts

 

 

Hello everyone first let me just say I have not actually started this script I have been confused on how to go about doing this and what would be easy and efficient. I have a webpage that has multiple div boxes, each with a unique id (b1, b2, etc) and the same class ("box"). The idea is that people try to pick the right boxes out of all of them. So I need a script where users can click on  ten different boxes (or links in the box) and then the script should check if those are the right boxes then either return with you win or you don't win.

 

My questions are:

Can this be done using php?

Should there be two scripts? (one that inserts the box value into a form & one that checks the form values with the winning values)

Is their a script already made that would work for this?

 

Thank you for checking this out, I’m not asking anyone to do all the hard work for me or hold my hand through it I just simply need to know where to start or get a basic idea of what the script would look like. All help is appreciated, any questions or need more information just ask.

 

Link to comment
Share on other sites

I would go for an AJAX aproach, adding picked boxes in a db by a php backend file - if done with pure php you must have each click reloading the page adding up the picked boxes in a session array or to db.

Another variant is ofcourse to use javascript adding picked boxes either to a cookie or collecting all div id's in a hidden textfield that is treated by php on submitting the result page.

 

im sure there are many ways of doing it, i would go for the AJAX method.

Link to comment
Share on other sites

I think an even easier solution is to just modify how you are selecting the boxes. Instead of using links, which require you to submit the page or use AJAX, you could just have a checkbox in each div. Then the user can select 10 checkboxes and submit their answer.

 

Using the above method you can simply store the correct answer in a session variable and check the response without needing a database.

Link to comment
Share on other sites

Thank you both of these helped, I just needed to know where to start researching. I have been using dreamweaver to design this page and I will look into using the spry check boxes and validation features I never even thought of doing it that way. Thank you!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.