第三个任务,我这样写不对吗???
function checkone(){
var j=document.getElementById("wb").value;
var hobby=document.getElementsByName("hobby");
var i=j-1;
hobby[i].checked=true;
function checkone(){
var j=document.getElementById("wb").value;
var hobby=document.getElementsByName("hobby");
var i=j-1;
hobby[i].checked=true;
2016-02-01
就算可以也不能算对,要求是用ID来实现,上面写的都不是用ID来实现的
//由ID实现 function checkone1(){ var j=document.getElementById("wb1").value; var hobby = document.getElementsByName("hobby"); if(j>0&&j<hobby.length+1){ for(var i=0;i<1;i++){ var x = document.getElementById("hobby"+j) if(x){ clearall(); x.checked = true; } } }else{ alert("1-6"); } //由ID实现 function checkedone(){ var hobby = document.getElementsByName("hobby"); var j = document.getElementById("select").value; if(j<hobby.length+1){ for(var i=0;i<hobby.length;i++){ if(hobby[i].id.charAt(5) == j){ hobby[i].checked = true; }else{ hobby[i].checked = false; } } }else{ alert("你输入越界请重新输入"); } }
举报