Jump to content

Using js to get checkbox value


clairian

Recommended Posts

Hi,

 

I am trying to use checkboxes so that when you select or deselect the checkbox it automatically sends the value (on/off) of that checkbox with a page refresh. However, at the moment (using the code below) when i check the box it refreshes the page with the value of property as 'on', but leaves the checkbox unchecked, so i can never deselect the checkbox to make the value of property 'off'. Any help would be greatly appreciated.

 

$property = $_GET['property'];

 

<form method="get" action="PropMain.php" name="Name">

<img src="MapsIcons/house.png" /> <input type="checkbox" name="property" onclick="checkHouse()"/>

</form>

 

function checkHouse()

{

if (Name.property.value != "")

    {

    Name.submit();

    }

}

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.