请问如何判断radio按钮是否被选中?
我下面的代码对吗?如果不对的话请帮助我指出那里错了
谢谢了?
我是想把选中的按钮的value值显示在text里面
<script>
function showRadio()
{
if(x.a.checked==true)
{
text.value=x.a.value;
}
}
</script>
<form name="x" >
<input type="radio" value="喜欢" name="a">喜欢
<br>
<input type="radio" value="不喜欢" name="a" >不喜欢
<br>
<input type="text" name="text" >
<br>
<input type="button" name="c" value="确定" onclick="showRadio()">
</form>
我下面的代码对吗?如果不对的话请帮助我指出那里错了
谢谢了?
我是想把选中的按钮的value值显示在text里面
<script>
function showRadio()
{
if(x.a.checked==true)
{
text.value=x.a.value;
}
}
</script>
<form name="x" >
<input type="radio" value="喜欢" name="a">喜欢
<br>
<input type="radio" value="不喜欢" name="a" >不喜欢
<br>
<input type="text" name="text" >
<br>
<input type="button" name="c" value="确定" onclick="showRadio()">
</form>
解决方案 »
- javascript错了不知道哪错了,求高手指点
- JSP 全局变量
- HTTP.status=0是怎么回事啊
- 高难度界面显示问题,烦请斑竹及各位高手看看,顶者有分。
- 表格存取为Excel文件求助
- 急!!!!!!!! 控制窗口的toolbar的 javascript 函数
- window.createPopup() 在ie6运行正确在ie5中则不正确
- 很怪的javascript问题
- jquery mobile如何使用自定义样式控制button的大小
- form表单图片上传,当没有选择图片时,文件储存地址会出现没有后缀名的图片
- 一个空的<div></div>标签也可以得到索引号吗
- 这个树形checkbox,如何添加代码实现目录自动隐藏和显示呢?
function showRadio()
{
if(document.all.x.a[0].checked==true)
{
document.all.x.text.value=document.all.x.a[0].value;
}
if(document.all.x.a[1].checked==true)
{
document.all.x.text.value=document.all.x.a[1].value;
}
}
</script>
<form name="x" >
<input type="radio" value="喜欢" name="a" onclick="showRadio()">喜欢
<br>
<input type="radio" value="不喜欢" name="a" onclick="showRadio()">不喜欢
<br>
<input type="text" name="text" >
<br>
<input type="button" name="c" value="确定" />
</form>
function showRadio()
{
if(document.getElementById("radio_1").checked == true){
document.x.text.value = document.getElementById("radio_1").value;
}
else{
document.x.text.value = document.getElementById("radio_2").value;
}
}
</script>
<form name="x" >
<input type="radio" id="radio_1" value="喜欢" name="a">喜欢
<br/>
<input type="radio" id="radio_2" value="不喜欢" name="a" >不喜欢
<br/>
<input type="text" name="text" >
<br/>
<input type="button" name="c" value="确定" onclick="showRadio()">
</form>