我想仅在选择组合框的值时显示文本框,否则应将其隐藏。我需要在同一页面中使用多个。感谢您的帮助。
<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>';
慕田峪9158850
相关分类