Jump to content

Checkboxes: on/off status


clairian

Recommended Posts

Hi,

 

I'm new to php/html and am having some trouble with my checkboxes. I want to use the on/off value of checkboxes to filter some data. The user selects the ones that they want on and then filter, which refreshes the page and passes the on/off values. However, the checkbox always goes back to being unchecked regardless of it the value selected is on or off. Any ideas how i can get the checkboxes to read whether they should be on or off. Any help would be greatly appreciated.

 

$property = $_GET['property'];

$supermarket = $_GET['supermarket'];

 

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

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

<img src="MapsIcons/basket.png" /><input type="checkbox" name="supermarket"/>

<P><input name="Refresh" type="submit" value="Filter">

</form>

Link to comment
https://forums.phpfreaks.com/topic/97111-checkboxes-onoff-status/
Share on other sites

<?php
$property = $_GET['property'];
$supermarket = $_GET['supermarket'];
?>
<form method="get" action="PropMain.php" name="Amenity">
<img src="MapsIcons/house.png" /> <input type="checkbox" name="property" <?php if($propery) print 'CHECKED';?> />
<img src="MapsIcons/basket.png" /><input type="checkbox" name="supermarket" <?php if($supermarket) print 'CHECKED';?> />
<P><input name="Refresh" type="submit" value="Filter">
</form>

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.