admin管理员组文章数量:1401491
I'm trying to do something a bit more plicated than this, but I broke it down and threw it in JSFIDDLE
and I still can't get it to work.
Any suggestions?
JSFiddle
HTML:
<label for="service-type">Value</label>
<select id="service-type" onChange="hamburger()">
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
<label for="receiptNo">No</label>
<input type="radio" name="receipt" id="receiptNo">
<label for="receiptYes">Yes</label>
<input type="radio" name="receipt" id="receiptYes">
Javascript:
var e = document.getElementById("service-type");
var ServiceUser = e.options[e.selectedIndex].text;
function hamburger() {
if (ServiceUser.value === "2") {
document.getElementById("receiptNo").disabled = true;
document.getElementById("receiptYes").checked = true;
}
}
I'm trying to do something a bit more plicated than this, but I broke it down and threw it in JSFIDDLE
and I still can't get it to work.
Any suggestions?
JSFiddle
HTML:
<label for="service-type">Value</label>
<select id="service-type" onChange="hamburger()">
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
<label for="receiptNo">No</label>
<input type="radio" name="receipt" id="receiptNo">
<label for="receiptYes">Yes</label>
<input type="radio" name="receipt" id="receiptYes">
Javascript:
var e = document.getElementById("service-type");
var ServiceUser = e.options[e.selectedIndex].text;
function hamburger() {
if (ServiceUser.value === "2") {
document.getElementById("receiptNo").disabled = true;
document.getElementById("receiptYes").checked = true;
}
}
Share
Improve this question
edited Dec 11, 2013 at 5:35
Vinay Jain
2,6343 gold badges27 silver badges44 bronze badges
asked Dec 11, 2013 at 4:58
CorporalArisCorporalAris
431 gold badge1 silver badge3 bronze badges
1 Answer
Reset to default 3Send the details of function caller like this
<select id="service-type" onchange="hamburger(this)">
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
<input type="radio" name="receipt" id="receiptNo">
<input type="radio" name="receipt" id="receiptYes">
Finish it up with javascript
<script type="text/javascript">
function hamburger(sender) { // sender here has all details of dropdown
if (sender.value === "2") {
document.getElementById("receiptNo").disabled = true;
document.getElementById("receiptYes").checked = true;
}
}
</script>
本文标签: htmlJavascript to disable or enable radio buttonsStack Overflow
版权声明:本文标题:html - Javascript to disable or enable radio buttons - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744243922a2596919.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论