【发布时间】:2014-03-29 20:41:12
【问题描述】:
我在互联网上搜索了一段时间,但找不到我想要的。
How to disable a text field when there is a select drop down selected with value (not emtpy)?
另外,切换它会很好。如果在“选择”下拉(无值)中没有选择选项时,则用户可以在文本字段中键入
我发现了一些类似的代码,但它在这里检查值是否等于“/\Custom\b/gi”我希望它检查是否选择了某些东西?
$('#Select_Font, #Enter_Text').attr('disabled', 'disabled');
$('.dropdownstyle').change(function () {
var present = $(this).val().match(/\Custom\b/gi) == null ? true : false;
if(present){
$('#Select_Font, #Enter_Text').attr('disabled', 'disabled');
}
else{
$('#Select_Font, #Enter_Text').removeAttr('disabled');
}
});
来源:How to enable or disable drop-down or text-box on selection other drop-down?
这可能吗?提前致谢。
编辑:
html
<div class='row'>
<div class="large-6 columns">
<label for="group">Group
<select name="selectGroup" id="selectGroup">
<option value="">Choose a group</option>
<?php
while ($row = $result->fetch_assoc()) {
echo '<option value="' . $row['group'] . '">' . $row['group'] . '</option>';
}
?>
</select>
</label>
</div>
<div class="large-6 columns">
<label for="group">Or make a new group
<input type="text" name="makeGroup" id="makeGroup"/>
</label>
</div>
</div>
【问题讨论】:
-
相关的 HTML 是什么?
标签: javascript jquery html css