我想在js文件中获取单选按钮的检查值。
for (var i = 0; i < radio_button.length; i++) {
if(radio_button[i].checked){
return radio_button[i].value;
}
}
return undefined;
}
new Ajax.Request("books.php", {
method:"GET",
parameters: {category:getCheckedRadio($$("div#category input.category"))},
onSuccess: showBooks_JSON,
onFailure: ajaxFailed
})
}
b_xml是单选按钮的ID,如果它具有onclick事件, 创建一个ajax请求,并通过调用函数在books.php中查找参数 但这不起作用。
<label><input type="radio" name="category" value="children" checked="checked"/> Children</label>
<label><input type="radio" name="category" value="computers" /> Computers</label>
<label><input type="radio" name="category" value="cooking" /> Cooking</label>
<label><input type="radio" name="category" value="finance" /> Finance</label>
这是html代码。