亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

一一啟用html表單域

一一啟用html表單域

慕娘9325324 2021-11-25 15:18:52
我有一個包含字段 ABA11,ABA12,ABA13 的表單......用于更新數據。在這個表格中,除了最初的第一個字段 ABA11 之外,所有字段都應保持禁用模式。一旦填充了 ABA11 字段,則只有 ABA12 將被啟用輸入數據。一旦輸入數據并保存在數據庫中,此后填充也應處于禁用模式。其他字段將繼續此過程<?php$status11=disabled;if(htmlentities($result->aba11)==null){    $status11=enabled;}?><td><input type="datetime-local"  name="aba11" id="aba11" value="<?php echo htmlentities($result->aba11);?>" class="form-control" <?php echo $status11?> ></td> <?php$status12=disabled;if(htmlentities($result->aba11)!=null and htmlentities($result->aba12)== null ){    $status12=enabled;}?><td><input type="datetime-local" name="aba12" onkeydown="upperCaseF(this)" value="<?php echo htmlentities($result->aba12);?>" class="form-control" <?php echo $status12?>></td><td><input type="text" name="aba13" onkeydown="upperCaseF(this)" value="<?php echo htmlentities($result->aba13);?>" class="form-control"></td></tr><tr><th class= "col-md-1.5" align="centre">0.0.1M NaOH</th><th class= "col-md-2" align="centre">60 Degree C</th><td><input type="datetime-local"  name="aba21"onkeydown="upperCaseF(this)" value="<?php echo htmlentities($result->aba21);?>" class="form-control" ></td> <td><input type="datetime-local" name="aba22" onkeydown="upperCaseF(this)" value="<?php echo htmlentities($result->aba22);?>" class="form-control" ></td><td><input type="text" name="aba23" onkeydown="upperCaseF(this)" value="<?php echo htmlentities($result->aba23);?>" class="form-control" ></td></tr>我嘗試使用 if 條件,但我無法實現它。請在此提出任何線索或我的錯誤。我只輸入了 if 條件 aba12。
查看完整描述

1 回答

?
慕少森

TA貢獻2019條經驗 獲得超9個贊

我已經修改了你的部分代碼來做到這一點。首先,您無法使用 PHP 來執行此操作,因為它是在服務器端加載頁面之前執行的,因此您需要為此使用 javascript。


我已經刪除了用于啟用/禁用輸入元素的 PHP 代碼。我只為前兩個元素制定了解決方案(您必須為其余的元素執行此操作,因此當您進入頁面時,您的aba11已啟用,其余的將被禁用。一旦您設置了輸入aba11(因為您有一個事件oninput),它disable_items使用一個數字調用 javascript 函數(這個數字表示我們正在處理的字段。javascript 函數禁用實際元素并啟用下一個元素。


<td><input type="datetime-local"  oninput="disable_items(1)" name="aba11" id="aba11" value="<?php echo htmlentities($result->aba11);?>" class="form-control" <?php echo $status11?> ></td> 


<td><input type="datetime-local" disabled oninput="disable_items(2)" name="aba12" onkeydown="upperCaseF(this)" value="<?php echo htmlentities($result->aba12);?>" class="form-control" <?php echo $status12?>></td>

<td><input type="text" disabled name="aba13" onkeydown="upperCaseF(this)" value="<?php echo htmlentities($result->aba13);?>" class="form-control"></td>

</tr>


<tr>

<th class= "col-md-1.5" align="centre">0.0.1M NaOH</th>

<th class= "col-md-2" align="centre">60 Degree C</th>


<td><input type="datetime-local"  disabled name="aba21"onkeydown="upperCaseF(this)" value="<?php echo htmlentities($result->aba21);?>" class="form-control" ></td> 

<td><input type="datetime-local" disabled name="aba22" onkeydown="upperCaseF(this)" value="<?php echo htmlentities($result->aba22);?>" class="form-control" ></td>

<td><input type="text" disabled name="aba23" onkeydown="upperCaseF(this)" value="<?php echo htmlentities($result->aba23);?>" class="form-control" ></td>

</tr>


<tr>

<th class= "col-md-1.5" align="centre">0.5M HCL</th>

<th class= "col-md-2" align="centre">60 Degree C</th>


<td><input type="datetime-local"  disabled name="aba31" onkeydown="upperCaseF(this)" value="<?php echo htmlentities($result->aba31);?>" class="form-control" ></td> 

<td><input type="datetime-local" disabled name="aba32" onkeydown="upperCaseF(this)" value="<?php echo htmlentities($result->aba32);?>" class="form-control" ></td>

<td><input type="text" disabled name="aba33" onkeydown="upperCaseF(this)" value="<?php echo htmlentities($result->aba33);?>" class="form-control"></td>

</tr>


<tr>

<th class= "col-md-1.5" align="centre">Freeze Drying</th>

<th class= "col-md-2" align="centre"> </th>

<td><input type="datetime-local" disabled name="aba41" onkeydown="upperCaseF(this)" value="<?php echo htmlentities($result->aba41);?>" class="form-control" ></td> 

<td><input type="datetime-local" disabled name="aba42" onkeydown="upperCaseF(this)" value="<?php echo htmlentities($result->aba42);?>" class="form-control" ></td>

<td><input type="text" disabled name="aba43" onkeydown="upperCaseF(this)" value="<?php echo htmlentities($result->aba43);?>" class="form-control"></td>

</tr>

</table>


<script>

function disable_items(option) {

    if (option==1){

        document.getElementById("aba11").disabled=true;

        document.getElementById("aba12").disabled=false;

    }

    if (option==2){

        document.getElementById("aba12").disabled=true;

        document.getElementById("aba13").disabled=false;

    }   

}


</script>



查看完整回答
反對 回復 2021-11-25
  • 1 回答
  • 0 關注
  • 125 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號