在GridView中使用radioButoon
在GridView中使用radioButoon
方法一:
<input type="radio" id='radioSelectFeed' name="radioDatafeedGroup" runat="server" onclick="radioBtnClick(this);" />
<input type="hidden" id="hiddenSelectedDataId" class="hiddenSelectedDataId" runat="server" />
javascript:
var lastRadioSelected = null;
function radioBtnClick(obj, dataId) {
if (lastRadioSelected == null) {
lastRadioSelected = obj.id;
alert(lastRadioSelected);
}
else {
var radio = document.getElementById(lastRadioSelected);
radio.checked = "";
alert(lastRadioSelected + " " + radio.checked);
lastRadioSelected = obj.id;
}
alert(datafeedId);
$('.hiddenSelectedDataId').val(dataId);
obj.checked = "checked";
}
方法二:
<input type="radio" id='radioSelectFeed_<%# Eval("ID") %>' name="radioDatafeedGroup" onclick="radioBtnClick(<%# Eval("ID") %>);" />
function radioBtnClick(dataId) {
alert(dataId);
$(".hiddenSelectedDataId").val(dataId);
alert($(".hiddenSelectedDataId").val());
}