js 获取select CheckBox

js获取select的值

<select name="selected" onchange="select()">     <option selected>--请选择--</option>     <option >cs</option>     <option >lol</option> </select>  var select = document.getElementsByName("selected")[0].value;

js获取CheckBox的值

<input type="checkbox" name="aihao" value="0" />0&nbsp;&nbsp; <input type="checkbox" name="aihao" value="1" />1&nbsp;&nbsp; <input type="checkbox" name="aihao" value="2" />2&nbsp;&nbsp;  var obj=document.getElementsByName('aihao'); for(var i=0; i<obj.length; i++){     if(obj[i].checked){  //查看被选中的值     }   }

分享