这是我的cakephp生成的
HTML广播框和文本框脚本:
<input type="radio" id="need_staff_on_site" name="data[CaterRequest][need_staff_on_site]" value="yes" class="staff_on_site"><span>Yes</span> <input type="radio" id="need_staff_on_site" name="data[CaterRequest][need_staff_on_site]" class="staff_on_site" value="no"><span>No</span> How many staff?<input type="text" maxlength="3" id="no_of_staff" name="data[CaterRequest][staff_needed]" class="txtboxSml2" readonly="readonly">
jquery脚本:
$(document).ready(function(){ $('.staff_on_site').click(function(){ $arr=$(this).val(); if($arr == "yes"){ $("#no_of_staff").removeAttr("readonly"); } if($arr == "no"){ $("#no_of_staff").attr("readonly","readonly"); } }); });
解决方法
在您的案例中,您可以编写以下jquery代码:
$(document).ready(function(){ $('.staff_on_site').click(function(){ var rBtnVal = $(this).val(); if(rBtnVal == "yes"){ $("#no_of_staff").attr("readonly",false); } else{ $("#no_of_staff").attr("readonly",true); } }); });
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。