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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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.