|
|
|
จะเขียนโค้ด js ยังไงให้ดึงค่า input text ที่เรากรอกมา โดยที่ไม่ต้องกด submit แล้วให้ ช่อง checkbox ในหน้า pageนั้นเลือกตามจำนวน ค่าที่เรากรอกคะ |
|
|
|
|
|
|
|
ลองดูพวก JavaScript Event เช่น OnChage , KeyPress , KeyDown ประมาณนี้ครับ
|
|
|
|
|
Date :
2012-11-21 12:16:24 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
session_start();
session_destroy();
$booking = $_REQUEST['booking_name'];
$cheap = $_REQUEST['cheap'];
$chic = $_REQUEST['chic'];
$boutique = $_REQUEST['boutique'];
?>
<script language="JavaScript" type="text/javascript">
function checkChang(){
var t = setTimeout("document.booking.submit();",0); //2 seconds measured in miliseconds
}
</script>
<div>BOOKING PROGRAM</div>
<table width="100%" border="0" cellspacing="0" cellpadding="2" align="center">
<tr>
<td height="35" colspan="2">Reservation information</td>
</tr>
<tr>
<td width="27%">Program Name:</td>
<td width="73%"><?php echo $booking ;?></td>
</tr>
<tr>
<td height="30">Price:</td>
<td height="30">6,340 THB
<?php
if($cheap==""){
echo "";
}else{
//$total1 = 6340+6304;
//$total2 = 6340+4250;
//$total3 = 6340+6840;
if($cheap=="5 Days at Bangkok 6,340 THB"){
echo $cheap;
echo " ";
//echo "<b>Totel</b>"." ".$total1." "."THB";
}
else if($cheap=="5 Days at Chaing Mai 4,250 THB"){
echo $cheap;
echo " ";
//echo "<b>Totel</b>"." ".$total2." "."THB";
}else{
echo $cheap;
echo " ";
//echo "<b>Totel</b>"." ".$total3." "."THB";
}
}
if($chic==""){
echo "";
}else{
echo $chic;
echo " ";
//echo "<b>Totel</b>"." ".$total2." "."THB";
}
if($boutique==""){
echo "";
}else{
echo $boutique;
echo " ";
//echo "<b>Totel</b>"." ".$total3." "."THB";
}
?>
</td>
</tr>
<!--
<tr>
<td height="30">Arrival date:</td>
<td height="30"><script>DateInput('sdate', true, 'yyyy-mm-dd')</script></td>
</tr>
<tr>
<td height="30" valign="top">Number of people:</td>
<td height="30">
<select name="select" id="select">
<option value="---- Selection ---">---- Selection ---</option>
</select>
Adult (s)<br />
<select name="select2" id="select2">
<option value="---- Selection ---">---- Selection ---</option>
</select>
Child (3-12 years)<br />
<select name="select3" id="select3">
<option value="---- Selection ---">---- Selection ---</option>
</select>
Infant</td>
</tr>
-->
<form id="booking" name="booking" action="booking_program.php?booking_name=<?= $booking ?>" method="post">
<tr>
<td height="30" valign="top">Excursion additional:</td>
<td height="30">
1.Cheap
<select name="cheap" id="cheap" onchange ="checkChang()">
<option value="" name="---- Selection ---">---- Selection ---</option>
<option value="| [5 Days at Bangkok] Price 6,340 THB." name="5 Days at Bangkok">5 Days at Bangkok 6,340 THB </option>
<option value="| [5 Days at Chaing Mai] Price 4,250 THB." name=" 5 Days at Chaing Mai"> 5 Days at Chaing Mai 4,250 THB</option>
<option value="| [5 Days at Phuket] Price 6,840 THB." name="5 Days at Phuket ">5 Days at Phuket 6,840 THB </option>
</select>
<br />
2.Chic
<select name="chic" id="chic" onchange ="checkChang()">
<option value="" name="---- Selection ---">---- Selection ---</option>
<option value="| [5 Days at Bangkok] Price 13,475 THB " name="5 Days at Bangkok">5 Days at Bangkok 13,475 THB </option>
<option value="| [5 Days at Chaing Mai] Price 12,375 THB" name="5 Days at Chaing Mai"> 5 Days at Chaing Mai 12,375 THB </option>
<option value="| [5 Days at Phuket] Price 16,090 THB " name="5 Days at Phuket">5 Days at Phuket 16,090 THB </option>
</select>
<br />
3.Boutique
<select name="boutique" id="boutique" onchange ="checkChang()">
<option value="" name="---- Selection ---">---- Selection ---</option>
<option value="| [5 Days at Bangkok] Price 18,770 THB " name="5 Days at Bangkok">5 Days at Bangkok 18,770 THB </option>
<option value="| [5 Days at Chaing Mai] Price 15,920 THB" name="5 Days at Chaing Mai"> 5 Days at Chaing Mai 15,920 THB </option>
<option value="| [5 Days at Phuket] Price 21,090 THB" name="5 Days at Phuket">5 Days at Phuket 21,090 THB </option>
</select>
<br />
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="hidden" value="OK" name="value(Submit)" onclick="javascript:return Login_Form_Validator(document.parameter)" onmouseover="this.style.cursor='hand'"/>
</td>
</tr>
<tr>
<td>Total Price :</td>
<td>
<?php
$total = 6340;
$total1 = 4250;
$total2 = 6840;
$total_1 = $total+$total;
$total_2 = $total+$total1;
$total_3 = $total+$total2;
if($cheap==""){
echo number_format($total, 2 , '.' , ',' )." "."THB.";
}else{
echo number_format($total_1, 2 , '.' , ',' )." "."THB.";
}
?>
</td>
</tr>
</form>
</table>
|
|
|
|
|
Date :
2012-11-21 16:40:35 |
By :
attaporn |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ยังทำไม่ได้เลยอะคะ รบกวนช่วยเขียนตัวอย่างให้ดูหน่อยได้ไหมคะ
|
|
|
|
|
Date :
2012-11-26 01:36:24 |
By :
Besic |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|