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
https://forums.phpfreaks.com/topic/97104-using-js-to-get-checkbox-value/
Share on other sites

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.