0
我正在創建一個可視化表預訂系統,並且爲了表示某個表已預訂,它將被禁用。如何使用php條件語句向DOM元素添加/編輯輸入標籤或類的屬性?
*代碼是沒有這樣做,但是我正在試圖找出我第一次如何添加一個PHP條件語句**
PHP代碼中使用jQuery屬性:
<?php
include "php/dbconn.php";
$sql = "SELECT id FROM place";
$tables = mysqli_query($conn, $sql);
while ($tablesrow = mysqli_fetch_array($tables)) {
$flag = false;
#check muna kung walang schedule conflict
$sql = "SELECT place FROM reservation WHERE status=0 AND (date='$date' AND starttime <=
'$endtime' AND endtime >='$starttime;')";
$bookedresult = mysqli_query($conn, $sql);
while ($bookedrow = mysqli_fetch_array($bookedresult)) {
if ($bookedrow["place"] == $tablesrow["id"]) {
$flag = true;
// echo $bookedrow["place"];
}
}
if (!$flag) {
// echo "<option>" . $tablesrow["id"] . "</option>";
echo "<script>";`
` 然後內的JavaScript(這是PHP代碼的延續)其中,I希望禁用屬性添加到輸入複選框ID爲#tblc_1
$(window).load(function() {$('#tbl-c').attr('disabled', true);});
這是HTML複選框
<div class="tbl-c-cont">
<div class="tbl-c tbl-c1">
<span>
<input type="checkbox" id="tblc_1" value="tblc_1" name="tbl_id[]">
</span>
</div>
<div class="tbl-c tbl-c2 ">
<span>
<input type="checkbox" id="tblc_2" value="tblc_2" name="tbl_id[]">
</span>
</div>
它不工作,我沒有收到所取得的成果。