Jump to content

Updating Data Based On What Boxes Are Checked


real_illusions
 Share

Recommended Posts

Hi all,I'm looking for a way to go about this trick using jquery and ajaxI have a form with a few boxes, for example:box1 = 1, box2 = 2, box3 = 3 etc etc... Where box1 is the name, and 1 is the value. The checkboxes will always be a numerical value.Now, whenever someone checks the box, i would like a message below them to update the total without a page refresh. So, if boxes 1 and 3 were ticked, it would say 4, if boxes 1, 3 and 7 were checked, then the total 11, etc etc. There would be decimals involved, like 1.5 and 3.5 for example, if thats going to cause any trouble.How would I go about this using ajax and preferably jquery if possible??Any help would be appreciated :)

Edited by real_illusions
Link to comment
Share on other sites

Why does it need ajax though? These are calculations you can do in Javascript without sending anything to the server, so why do you want to send it to the server to do the calculations? Why not just do the calculations in Javascript without sending anything to the server?

Link to comment
Share on other sites

I think he's under the impression that changing text in a div requires a refresh of the page, hence why he might think that AJAX would solve that problem? (of displaying the summed value of his checkbox values in a div without refreshing the page).You can just make a function which will do this for you, with only javascript. try googling "change text in div"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...