我有一张表格:
<form onsubmit="return send(this)">
<div>
<input type="radio" id="1" name="check" value="check1" checked="checked">
<input type="radio" id="2" name="check" value="check2">
<input type="radio" id="3" name="check" value="check3">
</div>
</form>
和js:
function send(formObj) {
myFirebase.push({
checked: formObj.check.value
})
}
如何获取已检查的输入值并将其传递到对象键checked
?
答案 0 :(得分:0)
var radiochecked = "";
for(i in formObj.check) {
if(formObj.check[i].checked) {
radiochecked = formObj.check[i].value;
}
}
function send(formObj) {
myFirebase.push({
checked: radiochecked
}