开发者

How do I enable/disable a textbox when a radio button is clicked using javascript?

开发者 https://www.devze.com 2022-12-20 21:29 出处:网络
I have a radio button with a textbox.How do I enable/disable the textbox using the oncli开发者_StackOverflowck event of a radio button?That is, if the radio button is selected then the textbox should

I have a radio button with a textbox. How do I enable/disable the textbox using the oncli开发者_StackOverflowck event of a radio button? That is, if the radio button is selected then the textbox should be enabled or else disabled.

Here is my code below:

<INPUT TYPE="radio" name="type" id="type1">
<input type="text" name="name" value="<?php echo $name?>" onChange="javascript:enableField();"/>


<input type="radio" name="type" id="type1" onclick="toggleTextbox(this);" />
<input type="text" name="name" value="<?php echo $name?>" id="name1" />

<script type="text/javascript">
function toggleTextbox(rdo) {
    document.getElementById("name1").disabled = !rdo.checked;
}
</script>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号