我有無數的HTML輸入標籤,這需要用戶輸入,並將其發佈到一個變量,代碼:如何禁用一個HTML標籤
<form method = "post" action=""select.php>
<input id="nol" style="width: 280px;" type="text" name="searchdisease" placeholder="type diagnosis one">
<input id="nol" style="width: 280px;" type="text" name="searchdisease1" placeholder="type diagnosis two">
<input id="nol" style="width: 280px;" type="text" name="searchdisease2" placeholder="type diagnosis three">
</form>
那麼這個變量i其附加到SQL查詢檢索數據LIKE用戶輸入代碼:
$search_disease = $_POST['searchdisease'];
$search_disease1 = $_POST['searchdisease1'];
$search_disease2 = $_POST['searchdisease2'];
$query="SELECT diagnosis FROM medications WHERE diagnosis LIKE '%$search_disease%'";
$result= $con->query($query);
$query1="SELECT diagnosis FROM medications WHERE diagnosis LIKE '%$search_disease1%'";
$result1= $con->query($query1);
$query2="SELECT diagnosis FROM medications WHERE diagnosis LIKE '%$search_disease2%'";
$result2= $con->query($query2);
,然後將結果回顯到選擇標籤。 代碼:
<select id="disease" style="width: 40%;" name="tdisease">
<option value="">Select Disease</option>
<?php
while ($row=$result->fetch_array(MYSQLI_ASSOC)) {
?>
<option value="<?php echo $row['ICD10']?>"><?php echo $row['diagnosis'];?> </option>
<?php } ?>
</select>
<select id="disease" style="width: 40%;" name="tdisease1">
<option value="">Select Disease</option>
<?php
while ($row=$result1->fetch_array(MYSQLI_ASSOC)) {
?>
<option value="<?php echo $row['ICD10']?>"><?php echo $row['diagnosis'];?> </option>
<?php } ?>
</select>
<select id="disease" style="width: 40%;" name="tdisease2">
<option value="">Select Disease</option>
<?php
while ($row=$result2->fetch_array(MYSQLI_ASSOC)) {
?>
<option value="<?php echo $row['ICD10']?>"><?php echo $row['diagnosis'];?> </option>
<?php } ?>
</select>
所以我想知道我可以使用JavaScript來禁用或隱藏選擇標籤,當用戶輸入是空的?
你嘗試過這麼遠嗎?也不應該多次使用相同的「ID」。 'ID'應該是唯一的。你能不能顯示'輸入'可能是空的......因爲這與你的問題有關。 – NewToJS
您不能對同一個元素使用相同的ID。 –
我還沒有嘗試過任何東西,也許我應該提到,我不知道JavaScript和JQuery – Morena