【发布时间】:2010-07-02 22:05:46
【问题描述】:
我尝试从输入框中的单选框中获取值
<form action="test()">
<input type="radio" name="typ" id="typ" value="ws" onfocus="test()" checked> ws
<input type="radio" name="typ" id="typ2" value="nb" onfocus="test()"> nb
<input type="radio" name="typ" id="typ3" value="za" onfocus="test()"> za
<input type="radio" name="typ" id="typ4" value="zb" onfocus="test()"> zb
</form>
这是我的 js:
<script type="text/javascript">
function test(){
document.getElementById('serverid').value=document.getElementById('typ').value;
}
function test(){
document.getElementById('serverid').value=document.getElementById('typ2').value;
}
function test(){
document.getElementById('serverid').value=document.getElementById('typ3').value;
}
function test(){
document.getElementById('serverid').value=document.getElementById('typ4').value;
}
</script>
这是我的输入框,在这里我将获取单选框的值:
<input type="text" style="background-color:#ffffff" size="15" name="ID" id="serverid">
但是每次输入框中都是zb,但我会选择:-)我希望你能理解我,我很抱歉我的英语。
我希望有人可以帮助我。
【问题讨论】:
标签: javascript input radio-button