如何检查是否使用JavaScript检查单选按钮?

时间:2015-03-25 00:26:29

标签: javascript html forms radio-button

当我选择单选按钮然后单击下载按钮时,没有任何反应。没有警报显示或任何东西。

这是我现在的代码:

HTML:

<form id="Resume_Select">
<input type="radio" name="resume_type" value="Economics" >Economics
<br />
<input type="radio" name="resume_type" value="MIS" >Management Information Systems
<br />
<button onClick="resume_select()"> Download</button>
</form>

JavaScript的:

<script>
    function resume_select(){
    var radios = document.getElementByName('resume_type');
    for(var i = 0, length = radios.length; i<length;i++){

        if(radios[i].checked){
            var resume = radios[i].value;
            alert(radios[i].value);
            break;
        }
    }

</script>

1 个答案:

答案 0 :(得分:4)

应该是getElementsByName复数而不是getElementByName。第一件事就是我。

相关问题