|
 |
|
อยากสอบการการ สร้างเงื่อนในการกด ปุ่ม แล้วเมื่อกดแล้วไม่ให้ กดได้อีก ให้เป็นค่า Flase ไม่สามารถกดได้อีก |
|
 |
|
|
 |
 |
|
ประมาณนี้ครับ 
Code (PHP)
<input type="Submit" value="Submit" onclick="this.disabled=1; this.form.submit();">
|
 |
 |
 |
 |
Date :
2014-02-05 08:15:19 |
By :
namebom |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<center><table width="100%" border="1" cellpadding="2" cellspacing="0" bordercolor="#F29179">
<tr>
<tr bgcolor="#FF99CC">
<th height="36" colspan="11" bgcolor="#F5D3A3" scope="col"><span class="style1">Order</span> </th>
</tr>
<tr bgcolor="#E6F5B6">
<th width="6%" bgcolor="#E6F5B6">Order Id</th>
<th width="15%" bgcolor="#E6F5B6">Customer Name</th>
<th width="5%" bgcolor="#E6F5B6">Amount</th>
<th width="5%" bgcolor="#E6F5B6">Point</th>
<th width="10%" bgcolor="#E6F5B6">Order Time</th>
<th width="25%" bgcolor="#E6F5B6">Confirm Point</th>
<th width="25%" bgcolor="#E6F5B6">Status</th>
</tr>
<?php
$sql = "select oid,odate,ship_name,grandtotal,osname,point,o.osid,cid
from orders as o
inner join orderstatus as os
on o.osid=os.osid
order by oid desc";
$result = mysql_query($sql) or die($sql);
$num = mysql_num_rows($result);
for ($i=1; $i<=$num; $i++){
$row = mysql_fetch_array($result);
$color=(@$color=="#ffffff")?"#81b39c":"#ffffff";
?>
<tr bgcolor="<?php echo $color?>">
<th><a href="../../Cake/backoffice/orderdetail.php?oid=<?php echo $row["oid"] ?>"target="_blank"><?php echo $row["oid"] ?></a> <input type="hidden" name="hiddenField" id="<?php echo $row["oid"] ?>" />
<th><?php echo $row["ship_name"] ?></th>
<th><?php echo $row["grandtotal"] ?></th>
<th><?php echo $row["point"] ?></th>
<th><?php echo $row["odate"] ?></th>
<th><input type="submit" name="button" id="button" value="Update Point"
onClick="window.location='updatepoint.php?oid=<?php echo $row["oid"] ?>'">
<input type="hidden" name="hiddenField" id="<?php echo $row["oid"] ?>"></th>
<th><?php echo $row["osname"]?></th>
</tr>
<?php }?>
</table></center>
|
 |
 |
 |
 |
Date :
2014-02-05 15:20:22 |
By :
Cake |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คือมันเป้นปุ่มแบบวนอ่าค่ะ เลยไม่รู้ว่า จะ disable หลังกด ปุ่ม ยังไงอ่ะค่ะ
|
 |
 |
 |
 |
Date :
2014-02-05 15:21:05 |
By :
Cake |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
1.)ในตารางข้อมูลมีฟิลด์ไหนที่ทำหน้าที่เก็บสถานะการอัพเดตหรือป่าว
-ถ้าไม่มี ก็ทำให้ปุ่ม disabled ไม่ได้ครับ เพราะมันเป็นการเรียกไฟล์ขึ้นมาใหม่อีกครั้ง จะจำสถานะที่เรากำหนดให้ disabled ไว้ไม่ได้ครับ
-ถ้าไม่มี อาจใช้ตัวแปร $_SESSION ซึ่งเราจะทำการผูกระหว่าง username หรือ session_id() กับ $row["oid"] ครับ แต่โค้ดก็จะเพิ่มความซับซ้อนขึ้นไปอีกหลายชั้น
-ถ้ามีก็ใช้วิธีเทียบกับในตารางข้อมูลว่า ผู้ใช้คนที่ล็อคอินเข้าระบบคนนี้ เคยอัพเดตข้อมูลหรือยัง แล้วเราค่อยจัดการเซ็ต disabled
2.) ไม่อย่างนั้นต้องปรับเปลี่ยนวิธีการส่งข้อมูลไปอัพเดตในเทเบิ้ลใหม่โดยใช้ AJAX/Jquery แล้วรอค่าส่งกลับมาเพื่อตรวจสอบว่าทำการอัพเดตข้อมูลเรียบร้อยแล้ว หลังจากนั้นค่อยเซ็ตปุ่มให้ disabled ครับ
|
 |
 |
 |
 |
Date :
2014-02-05 17:33:31 |
By :
sakuraei |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<tr bgcolor="<?php echo $color?>">
<th><a href="../../Cake/backoffice/orderdetail.php?oid=<?php echo $row["oid"] ?>"target="_blank"><?php echo $row["oid"] ?></a> <input type="hidden" name="hiddenField" id="<?php echo $row["oid"] ?>" />
<th><?php echo $row["ship_name"] ?></th>
<th><?php echo $row["grandtotal"] ?></th>
<th><?php echo $row["point"] ?></th>
<th><?php echo $row["odate"] ?></th>
<th><?php echo buttondisable ($row["pactivate"]==1) ?><input type="button" name="button" id="button" value="Update Point"
onClick="window.location='updatepoint.php?oid=<?php echo $row["oid"] ?>;'">
Code (PHP)
function buttondisable($int){
if ($int==1)
return "show";
else
return "hidden";
}
คือว่าถ้าจะใส่เงื่อนไขใน input ใส่ยังไงเอ่ยค่ะ ถ้า pactivate เป็น 1 ให้ ปุ่ม Button โชว์ ทำยังไงเอ่ยค่ะ คือ pactivate อยู่ใน DB นะค่ะ
|
 |
 |
 |
 |
Date :
2014-02-08 10:28:20 |
By :
Cake |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
7.<th><input type="button" name="button" id="button" value="Update Point"
8.onClick="window.location='updatepoint.php?oid=<?php echo $row["oid"] ?>;' "
<?php if($row["pactivate"]==1) echo " disabled "; ?> />
|
 |
 |
 |
 |
Date :
2014-02-08 11:05:41 |
By :
sakuraei |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากค่ะ จะจำจนตายเลยยย
|
 |
 |
 |
 |
Date :
2014-02-08 11:35:30 |
By :
Cake |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|