jim.jin 发表于 2013-2-7 20:37:32

js 得到radio选中的直

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" dir="ltr"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/><title>Get radio values demo</title><script type="text/javascript">var getRadioValues = function(){    var inputs = document.getElementsByTagName('input')    var values=""    for(i=0; i<inputs.length; i++) {      obj = inputs;      t = obj.getAttribute("type");      if(t=='radio' && obj.checked){      v = obj.getAttribute("value");      values += v;      }    }    return values;}</script></head><body><label><input type="radio" name="radio" value="0">不开通</label><label><input type="radio" name="radio" value="1" checked=checked>开通</label><label><input type="radio" name="radio1" value="0" checked=checked>允许</label><label><input type="radio" name="radio1" value="1">不允许</label>   <input type="button"value="Get values" /></body></html>
页: [1]
查看完整版本: js 得到radio选中的直