我想僅在選擇組合框的值時顯示文本框,否則應將其隱藏。我需要在同一頁面中使用多個。感謝您的幫助。<label>1- Are there are friends/ neighbours/ family providing help ?</label><select class="form-control" name="formlist[any_friends_relatives_help3]" class="selincrease" id="edition" onchange="func()" style="height: 5%;"> <option value="">choose...</option> <?php if (isset($forms['any_friends_relatives_help3'])) { echo '<option selected="selected" value="' . $forms['any_friends_relatives_help3']. '" disabled>' . $forms['any_friends_relatives_help3'] . '</option>' ; echo '<option value="<?=$forms[\'any_friends_relatives_help3\'] ?? \'Yes\'?>">Yes</option>' ; echo ' <option value="<?=$forms[\'any_friends_relatives_help3\'] ?? \'No\'?>">No</option>'; ?> <?php } else {?> <option value="<?=$forms['any_friends_relatives_help3'] ?? 'Yes'?>">Yes</option> <option value="<?=$forms['any_friends_relatives_help3'] ?? 'No'?>">No</option> <?php }?></select><div id="trhide"> <label>Please Specify:</label><br /> <textarea class="form-control" name="formlist[specify_help3]"><?=$forms['specify_help3'] ?? ''?></textarea></div><script type="text/javascript"> function func() { var elem = document.getElementById("edition"); if (elem.value == "Yes") { document.getElementById("trhide").style.visibility = "visible"; } else { document.getElementById("trhide").style.visibility = "hidden"; } }</script>如果我僅使用上面的一個,則它起作用,但是當我將另一個用于另一個選擇時,它們都不起作用。第二個代碼如下:<label>Shopping</label><select class="form-control" name="formlist[shopping3]" class="selincrease" id="change" style="height: 5%;" required="required"> <option value="">choose...</option> <?php if (isset($forms['shopping3'])) { echo '<option selected="selected" value="' . $forms['shopping3']. '" disabled>' . $forms['shopping3'] . '</option>' ; echo '<option value="<?=$forms[\'shopping3\'] ?? \'Self\'?>">Self</option>' ; echo ' <option value="<?=$forms[\'shopping3\'] ?? \'Other\'?>">Other</option>';
當從組合框中選擇了多個值時,如何顯示文本框
DIEA
2021-04-07 09:14:56