Jump to content

Help?


Highland3r

Recommended Posts

i need to change the way this code works.

 

at the moment when the code runs it brings up a default box which calculates the cost by the number of rooms i need it to calculate dependent on number of people.

<form name='booking' method='post' action='reservationform.php' onSubmit='return booking_validate()'>			<input type='hidden' id='arrival_date' name='arrival_date' value='".$this->print_arrival_date()."'>			<input type='hidden' id='leaving_date' name='leaving_date' value='".$this->print_leaving_date()."'>			<input type='hidden' id='nights' name='nights' value='".$this->nights()."'>";			while($result=$db->fetchAssoc()) {				$info .="<div class='rateheader'>							".$result['type_name']."						</div>						<div class='rate'>							<div class='innerrate'>							<p>								".stripcslashes($result['description'])."							</p>							Max Occupants: <b>".$result['max_occupants']."</b><br/>							Max Children: <b>".$result['max_childs']."</b><br/>							Price per night: <b>£".$result['default_price']."</b>						<br/><br/><br/>						Please select number of rooms and click reserve button below 						<table  cellspacing=1 cellpadding=1  border=0>							<tr>								<td> </td>							</tr>							<tr>								<td>Rooms</td>								<td style='display:none' id='adults_td[".$result['room_type_id']."]'>Adults</td>								<td id='price_td[".$result['room_type_id']."]' style='display:none'  >								   <nobr>Total Price</nobr>								</td>							</tr>							<tr>								<td>									<input type='hidden' name='max_adults[".$result['room_type_id']."]' id='max_adults[".$result['room_type_id']."]' value='".$result['max_occupants']."' />									<input type='hidden' name='price_hidden[".$result['room_type_id']."]' id='price_hidden[".$result['room_type_id']."]' value='".$result['default_price']."' />									<select id='number_rooms[".$result['room_type_id']."]' name='number_rooms[".$result['room_type_id']."]' 										onChange='ajax_calculate(".$result['room_type_id'].")'>										<option value='0' selected>0</option>";										for($i=1;$i<=$result['room_count'];$i++) {											$info .="<option value=".$i." >".$i."</option>";										}    									$info .="</select>    								</td>								<td id='adults_td1[".$result['room_type_id']."]' style='display:none;'>								</td>    								<td style='padding-left:12px;display:none;' id='price_td1[".$result['room_type_id']."]' >								  <B>£<span name='price[".$result['room_type_id']."]' id='price[".$result['room_type_id']."]'>0.00</span><input type='hidden' name='price[".$result['room_type_id']."]' value=''></B>								</td>							</tr>						</table>												<input type='submit' class='buttonstyle' name='btn' value='Reserve' title='Reserve this room' /><hr />						<br /><br />											</div>				</div><input type='hidden' name='validate' id='validate' value='0'>";			}			$info .="<script type='text/javascript'>						function ajax_calculate(room_type_id) {        							var price=document.getElementById('price_hidden['+room_type_id+']').value;							var number=document.getElementById('number_rooms['+room_type_id+']').options[document.getElementById('number_rooms['+room_type_id+']').selectedIndex].value;							var number_adults=document.getElementById('max_adults['+room_type_id+']').value;							var total_adults=number_adults*number;							var nights=document.getElementById('nights').value;							if (number!=0) {								document.getElementById('adults_td['+room_type_id+']').style.display='';								document.getElementById('adults_td1['+room_type_id+']').style.display='';								document.getElementById('price_td['+room_type_id+']').style.display='';								document.getElementById('price_td1['+room_type_id+']').style.display='';								document.getElementById('validate').value=1;							}							else {								document.getElementById('adults_td['+room_type_id+']').style.display='none';								document.getElementById('adults_td1['+room_type_id+']').style.display='none';								document.getElementById('price_td['+room_type_id+']').style.display='none';								document.getElementById('price_td1['+room_type_id+']').style.display='none';								document.getElementById('validate').value=0;							}							select_adult=\"<select id='adults[\"+room_type_id+\"]' name='adults[\"+room_type_id+\"]'>\";							for (var i=1;i<=total_adults;i++) {								select_adult+=\"<option value=\"+i+\">\"+i+\"</option>\";                       							}							select_adult+=\"</select>\";							var total_price=number*price*nights;							document.getElementById('adults_td1['+room_type_id+']').innerHTML=select_adult;							document.getElementById('price['+room_type_id+']').innerHTML=total_price;													}						</script>			</form>";

 

So at the moment when you open the program it asks how many rooms you require in my case it is always one but if you select 2 it doubles the price and so on, once you have selected the number of rooms it asks how many people 1 - 4 now doesnt matter what you select it doesnt change the price Help apreciated.

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.