Jump to content

How to use check box & javascript to reset a php Variable from true/false


KitCarl

Recommended Posts

A open source php software package I use has a boolean variable set in the config file that depending on its setting calls a block of code to be used on all pages. I would like to use a check box so the user will be able to toggle the function on and off for the current page by resetting the variable and reloading the page upon the onclick event. Can someone please explain how to go about this using javascript.

You need to use AJAX, and set an onclick listener to the checkbox. Then when the box is checked, you ping a URL on your server with your javascript. This script should be set to change the value of the boolean depending on whether the user just checked the box, or unchecked it.

Lots and lots and lots of tutorials out there. Google 'Ajax tutorials'. Figure out how AJAX works, after that follow the directions I gave you in the first post. It's really quite an easy usage of AJAX - there is no data returned or anything.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.