选择一个单选按钮,其他文本框或下拉框disable掉
来源:互联网 发布:网络在线客服的要求 编辑:程序博客网 时间:2024/06/14 10:48
javascript
================================================================================================
//吸烟
$('input[id=boolean_smoking]').change(function(){
//是否吸烟,选择否(把烟龄、日吸烟量、是否戒烟disable掉)
if(this.value == '0'){$('input[name=smokAge]').attr("disabled",true);
$('input[name=smokAge]').val("");
$('input[name=dailySmoking]').attr("disabled",true);
$('input[name=dailySmoking]').val("");
$('input[name=quitSmoking]').removeAttr("checked");
$('input[name=quitSmoking]').attr("disabled",true);
}if(this.value == '1'){
$('input[name=smokAge]').removeAttr("disabled");
$('input[name=dailySmoking]').removeAttr("disabled");
$('input[name=quitSmoking]').removeAttr("disabled");
}
});
//喝酒
$('input[id=boolean_drinking]').change(function(){
//是否喝酒,选择否(把酒龄、饮酒频率、是否戒酒disable掉)
$('input[name=drinkAge]').attr("disabled",true);
$('input[name=drinkAge]').val("");
$('input[name=quitDrinking]').attr("disabled",true);
$('input[name=quitDrinking]').removeAttr("checked");
$("#drinkingFrequency").val("");
$("#drinkingFrequency").attr("disabled",true);
}if(this.value == '1'){
$('input[name=drinkAge]').removeAttr("disabled");
$('input[name=quitDrinking]').removeAttr("disabled");
$("#drinkingFrequency").removeAttr("disabled");
}
});
jsp页面代码
================================================================================================
<div class="eat_right" style="font-size: 13px;">
<div class="item">
是否吸烟:
<input name="smoking" id="boolean_smoking" type="radio" value="1" <c:if test="${healthdataStatic.smoking eq 1 }">checked="checked"</c:if>/>是
<input name="smoking" id="boolean_smoking" type="radio" value="0" <c:if test="${healthdataStatic.smoking eq 0 }">checked="checked"</c:if> />否
</div>
<div class="item">
<input type="hidden" name="id" value="${healthdataStatic.id }">
烟 龄:
<input type="text" name="smokAge" class="smoker" value="${healthdataStatic.smokAge }"
style="width: 100px; height: 20px;" maxlength="3" <c:if test="${healthdataStatic.smoking eq 0 }">disabled="disabled"</c:if>/> 年
<span id="smoker" style="color: red;"> </span>
</div>
<div class="item">
日吸烟量:
<input type="text" name="dailySmoking" class="booder" value="${healthdataStatic.dailySmoking }"
style="width: 100px; height: 20px;" maxlength="3" <c:if test="${healthdataStatic.smoking eq 0 }">disabled="disabled"</c:if> /> 支
<span id="booder" style="color: red;"> </span>
</div>
<div class="item"><!-- 0320 -->
是否戒烟:
<input name="quitSmoking" type="radio" value="1" <c:if test="${healthdataStatic.smoking eq 0 }">disabled="disabled"</c:if><c:if test="${healthdataStatic.quitSmoking eq 1 }">checked="checked"</c:if> />是
<input name="quitSmoking" type="radio" value="0" <c:if test="${healthdataStatic.smoking eq 0 }">disabled="disabled"</c:if><c:if test="${healthdataStatic.quitSmoking eq 0 && healthdataStatic.smoking eq 1 }">checked="checked"</c:if>/>否
</div>
</div>
<div class="eat_right" style="border-top: 1px solid #1d5a99; margin-top: 20px; font-size: 13px;">
<div class="item">
是否饮酒:
<input name="drinking" id="boolean_drinking" type="radio" value="1" <c:if test="${healthdataStatic.drinking eq 1 }">checked="checked"</c:if>/>是
<input name="drinking" id="boolean_drinking" type="radio" value="0" <c:if test="${healthdataStatic.drinking eq 0 }">checked="checked"</c:if>/>否
</div>
<div class="item">
酒 龄:
<input type="text" name="drinkAge" class="a" value="${healthdataStatic.drinkAge }"
style="width: 100px; height: 20px; margin-left:;" maxlength="3" <c:if test="${healthdataStatic.drinking eq 0 }">disabled="disabled"</c:if> /> 年
<span id="a" style="color: red;"> </span>
</div>
<div class="item">
饮酒频率:
<select name="drinkingFrequency" id="drinkingFrequency" style="width: 105px" <c:if test="${healthdataStatic.drinking eq 0 }">disabled="disabled"</c:if>>
<option value="" ></option>
<option value="偶尔饮酒" <c:if test="${healthdataStatic.drinkingFrequency == '偶尔饮酒'}">selected="selected"</c:if>>偶尔饮酒</option>
<option value="每周1-2次 " <c:if test="${healthdataStatic.drinkingFrequency == '每周1-2次'}">selected="selected"</c:if>>每周1-2次 </option>
<option value="每周3次以上" <c:if test="${healthdataStatic.drinkingFrequency == '每周3次以上'}">selected="selected"</c:if>>每周3次以上</option>
<option value="每周醉酒" <c:if test="${healthdataStatic.drinkingFrequency == '每周醉酒'}">selected="selected"</c:if>>每周醉酒</option>
</select>
</div>
<div class="item"><!-- 0320 -->
是否戒酒:
<input name="quitDrinking" type="radio" value="1" <c:if test="${healthdataStatic.drinking eq 0 }">disabled="disabled"</c:if><c:if test="${healthdataStatic.quitDrinking eq 1 }">checked="checked"</c:if>/>是
<input name="quitDrinking" type="radio" value="0" <c:if test="${healthdataStatic.drinking eq 0 }">disabled="disabled"</c:if><c:if test="${healthdataStatic.quitDrinking eq 0 && healthdataStatic.drinking eq 1}">checked="checked"</c:if>/>否
</div>
</div>
- 选择一个单选按钮,其他文本框或下拉框disable掉
- 选择下拉框"其他" 弹出一个文本框
- JavaScript操作文本框、单选按钮、下拉框、复选框
- js前台页面定位选择下拉框,单选按钮
- 下拉框 单选按钮
- 下拉框+文本框+搜索按钮
- html表单(文本框、密码、单选、复选、提交、重置、普通、隐藏、文件按钮、下拉选项)
- 选择屏幕----下拉框,单选,多选
- 下拉框选择赋植给文本框
- 点击文本框时弹出单选(或复选)对话框,选择选项后在文本框中显示
- 选择复选框时清除按钮的disable属性
- JS实现单选按钮与下拉列表的值的选择,使与数据库保持一致
- select下拉列表 和 radio单选按钮控件开关---- 根据值选择选项 & change事件
- 通过单选按钮的value值判断一个文本框是否有用!求解决方案
- jquery EasyUI +MVC 页面有三个单选按钮,选择不停按钮展示不同的层,其他的隐藏
- extjs 文本框后加一个按钮或 文字
- 单选按钮 、 下拉框 、 复选框 选中问题
- HTML单选、多选、按钮、下拉框、文本输入框
- 深入剖析Tomcat 第一章 一个简单的Servlet服务器
- C++简单编程——选择语句进阶
- 时间选择器
- 无限循环滚动,从右到左,一次一条
- 获得IntelliJ IDEA激活码的方法
- 选择一个单选按钮,其他文本框或下拉框disable掉
- 为什么MYSQL要设定用UTF8MB4编码 UTF8MB4_UNICODE_CI
- MySQL基础数据库和表操作
- volatile二三事1
- 选择结构
- [Codeforces285E]Positions in Permutations(dp+容斥原理+组合数学)
- 技术点详解---L2TP VPN
- 信息课日常
- 发布开源Library到JCenter