clairian Posted March 20, 2008 Share Posted March 20, 2008 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 More sharing options...
zenag Posted March 27, 2008 Share Posted March 27, 2008 try this friend .... function checkHouse() { if(document.getElementById("property").checked==true) { alert('checked'); } if(document.getElementById("property").checked == false) { alert('not checked'); } Link to comment https://forums.phpfreaks.com/topic/97104-using-js-to-get-checkbox-value/#findComment-501963 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.