Jump to content

How to change min and max prices depending on what radial button is selected?


usman07

Recommended Posts

I basically have a search form, and what I want is if the user selects 'For Sale' radial button then the minimum and maximum prices will start from £50,000 to £350,000 but if the users selects 'To Rent' then the minimum and maximum prices will change to 100 PCM to 400 PCM. any help would be appreciated.

 

A image is attached of the form.

 

Heres the PHP code for the search form:

<form action="insert.php" method="post">
<table id="tb1">
<tr>
<td><p class="LOC">Location:</p></td>
<td><div id="LC">
<?php
$locationSql = "SELECT id, area_name FROM locations GROUP by area_name";
$locQry = mysql_query($locationSql) or die (mysql_error());
echo "<select name=\"areas\" size=\"5\" style=\"width:150px;\">";
while ($location = mysql_fetch_assoc($locQry)){
echo "<option value=\"{$location['id']}\">{$location['area_name']}</option>";
}
echo "</select>";
?>
</div>
</td><td><p class="PT">Property type:</p></td>
<td><div id="PS">
<?php
$catSql = "SELECT id, cat_name FROM catagorys GROUP by cat_name";
$catQry = mysql_query($catSql) or die (mysql_error());
echo "<select name=\"prop_type\" size\"=5\" style=\"width:150px;\">";
while ($cat = mysql_fetch_assoc($catQry)){
echo "<option value=\"{$cat['id']}\">{$cat['cat_name']}</option>";
}
echo "</select>";
?>
</div>
</td>
<td>
<div id="ptype">

<input type="radio" class="styled" name="ptype" value="forsale"/> For Sale 

<p class="increase">
<input type="radio" class="styled" name="ptype" value="forrent"/> To Rent
</p>
<p class="increase">
<input type="radio" class="styled" name="ptype" value="any" checked="checked"/> Any
</p>

</div>
</td>  
</tr>

	</table>

	<div id="table2">
	<table id="NBtable">
	<tr>
	<td><p class="NBS">Number of bedrooms:</p></td>
	<td><div id="NB">

	<select name="min_bedrooms">
<?php
$roomLimit = 5;
for($minRooms = 0; $minRooms <= $roomLimit; $minRooms++){
  if ($minRooms == 0){
    echo"<option value=\"0\" selected=\"selected\">No Min</option>";
  }
  else{
    echo "<option value=\"$minRooms\">$minRooms</option>";
  }
}
?>
	</select> to

	<select name="max_bedrooms">
	<?php
$roomLimit = 5;
for($maxRooms = 0; $maxRooms <= $roomLimit; $maxRooms++){
  if ($maxRooms == 0){
    echo"<option value=\"0\" selected=\"selected\">No Max</option>";
  }
  else{
    echo "<option value=\"$maxRooms\">$maxRooms</option>";
  }
}
?>
	</select>	
	</div>
</td>

	<td><p class="PR">Price range:</p></td>
	<td><div id="PR">

	<select name="min_price" style='width:80px;'>
	<?php
$priceLimit = 350;
for($minPrice = 40; $minPrice <= $priceLimit; $minPrice =( $minPrice+ 10)){
  if ($minPrice == 40){
    echo"<option value=\"0\" selected=\"selected\">No Min</option>";
  }
  else{
    echo "<option value=\"$minPrice\">£$minPrice,000</option>";
  }
}
?>		</select> to

	<select name="max_price" style='width:80px;'>
	<?php
$priceLimit = 350;
for($maxPrice = 40; $maxPrice <= $priceLimit; $maxPrice =( $maxPrice+ 10)){
  if ($maxPrice == 40){
    echo"<option value=\"0\" selected=\"selected\">No Max</option>";
  }
  else{
    echo "<option value=\"$maxPrice\">£$maxPrice,000</option>";
  }
}
?>
	</select>

	</div>
</td>
</tr>

	</table>

	<div id="submit1"><input type="submit" name="submit" value="submit" /></div>
     
     
	</div>
	</form>		

 

Thanks in advance.

post-130660-13482403474386_thumb.png

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.