|
 |
|
ช่วยดู code .ให้ด้วยค่ะ ได้ code javascript เป็นการตรวจสอบการ update ถ้าสถานนะห้อง (status )ไม่ว่าง(B) |
|
 |
|
|
 |
 |
|
  
จะให้ตรวจสอบสถานะอย่างเดียวใช่ป่ะ
Code (PHP)
<script type="text/javascript">
function doSubmit(frm){
var status=getCheckedValue(frm.status);
if(status == "B"){
alert("สถานะตอนนี้คือไม่ว่าง ");
return false;
}
/*
if(frm.ข้อมูลอื่นๆ.value == ""){ // comment: ชื่อ ข้อมูลๆอื่น หมายความว่าไง
alert("กรอก ข้อมูลอื่นๆ");
return false;
}
if(rm.hdn_status.value == "ไม่ว่าง"){ // comment: ชื่อ hdn_status อยู่ไหนไม่เห็นมีเลย
alert("ไม่สามารถ update ข้อมูลได้");
return false;
}
*/
return true;
}
/*ฟังก์ชันตรวจสอบ radio ที่ถูกเลือก*/
function getCheckedValue(radioObj) {
if(!radioObj)
return "";
var radioLength = radioObj.length;
if(radioLength == undefined)
if(radioObj.checked)
return radioObj.value;
else
return "";
for(var i = 0; i < radioLength; i++) {
if(radioObj[i].checked) {
return radioObj[i].value;
}
}
return "";
}
</script>
<?
$host="localhost";
$username="root";
$password="";
$db="hotelmis";
$tb="rooms";
$connect= mysql_connect( $host,$username,$password) or die ("?????????????????? Mysql ?????? ");
mysql_select_db($db) or die("????????????????????");
$sql="select * from $tb where roomid=$roomid";
mysql_query("SET NAMES 'tis620'");
$db_query=mysql_db_query($db,$sql);
$result = mysql_fetch_array($db_query);
$roomid=$result[roomid];
$roomno=$result[roomno];
$floor=$result[floor];
$value_room=$result[value_room];
$aircondition =$result[aircondition ];
$fun =$result[fun ];
$status =$result[status ]
?>
<form name="myfrm" method="post" action="" onSubmit="return doSubmit(document.myfrm)">
<table width="95%" align="center">
<tr>
<td colspan="2"><span class="style4">rooms <?echo"<b>$roomno</b>";
?></span> <span class="style14">
<input name="roomid" type="hidden" id="roomid" value="<? echo"$roomid"; ?>" />
</span></td>
</tr>
<tr>
<td width="118">หมายเลขห้อง</td>
<td width="323"><input name="roomno" type="text" id="roomno" value='<? echo"$roomno";?>' /></td>
</tr>
<tr>
<td><label onClick="return (document.getElementById('checkbox_row_2') ? false : true)" for="checkbox_row_2"></label>
<label onClick="return (document.getElementById('checkbox_row_3') ? false : true)" for="checkbox_row_3">ชั้น</label></td>
<td><input name="floor" type="text" id="floor" value="<? echo"$floor ";?>" /></td>
</tr>
<tr>
<td><label onClick="return (document.getElementById('checkbox_row_3') ? false : true)" for="checkbox_row_3">ค่าห้อง</label></td>
<td><input name="value_room" type="text" id="value_room" value="<? echo"$value_room ";?>" /></td>
</tr>
<tr>
<td><p>แอร์</p>
<p> พัดลม</p></td>
<td><p align="left">
<input name="aircondition" type="checkbox" id="article" value="Y" <?echo $aircondition==Y? "checked":""?> />
</p>
<p>
<input name="fun" type="checkbox" id="article" value="Y" <?echo $fun==Y? "checked":""?> />
</p></td>
</tr>
<tr>
<td>สถานะ</td>
<td><table width="90%" border="0" cellpadding="1">
<tr>
<td ><input name="status" type="radio" value="V" checked="checked" <?echo $status==V? "checked":""?> />
ว่าง ( V )</td>
<td><input name="status" type="radio" value="B" <?echo $status==B? "checked":""?> />
ล็อก ( B )</td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><input name=" onsubmit" type="submit" id=" onsubmit" value="แก้ไขข้อมูล">
<input type="reset" name="Submit2" value="ยกเลิก"></td>
</tr>
<tr>
<td colspan="2"><div id="RequestDetails">
<input type="button" name="Submit3" value="รายการห้องเช่า" onClick="loadHTML('room_list.php','RequestDetails','room')"/>
</div></td>
</tr>
</table>
<p> </p>
<p> </p></td>
</tr>
</table>
<p> </p>
</form>
|
 |
 |
 |
 |
Date :
2009-10-18 13:08:11 |
By :
xbeginner01 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใช่ค่ะ ตรวจสอบอย่างเดี่ยว แค่อยากให้มันฟ้องขึ้นมา ถ้าสถานะห้อง เป็น B อยู่คือ update ไม่ได้นะค่ะ
|
 |
 |
 |
 |
Date :
2009-10-18 15:45:23 |
By :
aung |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทำได้แล้วขอบคุณมากค่ะ
|
 |
 |
 |
 |
Date :
2009-10-18 15:48:26 |
By :
aung |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
<script type="text/javascript">var _pbwid = 69144;</script>
<script type="text/javascript" src="http://www.picbadges.com/w/widget.js"></script>
|
 |
 |
 |
 |
Date :
2010-12-14 00:13:07 |
By :
hh |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|