Jump to content

PHP coding Help on drop down list


usman07

Recommended Posts

Basically I have a form and What I want it to do is when a user selects the 'For Sale' radio button the minimum and maximum prices will be displayed in the drop down list as "70,000"+ but when the user selects the 'To Rent' radial button then the minimum and maximum drop down list prices will change to e.g. "200"+. How would I do this?

 

Heres my Code for the form:


<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"/> 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=\"$minPrice000\">£$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=\"$maxPrice000\">£$maxPrice,000</option>";
  }
}
?>
	</select>

Thanks in advance.

Link to comment
Share on other sites

Unless you want the user to submit the form data after selecting the radio button, I'd say you need to use JavaScript. If you want to make it easier, you could load the prices along with everything else, but if there's a lot of items, you may want to look into combining your JavaScript with Ajax (JSON).

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.