不要忘记jquery库的引入
//获取radiobuttonlist 选中的 text :
function GetRbtnListByEdText(radiobuttonlistid) {
return $("#" + radiobuttonlistid).find("input:checked").next("label").text();
}
//获取radiobuttonlist 选中的 value :
function GetRbtnListByEdValue(radiobuttonlistid) {
return $("#" + radiobuttonlistid).find("input:checked").attr("value");
}
//获取radiobuttonlist 选中的 索引 :
function GetRbtnListByEdIndex(radiobuttonlistid) {
var targetObj = $("#" + radiobuttonlistid + " input");
var tempThis = $("#" + radiobuttonlistid).find("input:checked")
return targetObj.index(tempThis);
}
//设置radiobuttonlist 选中的 text :
function SetRbtnListByEdText(radiobuttonlistid, _txt) {
var tempThis;
var targetObj = $("#" + radiobuttonlistid + " label");
targetObj.each(function() {
tempThis = $(this);
if (tempThis.text() == _txt) {
tempThis.prev("input").attr("checked", "checked"); //.attr("disabled", "disabled");
return;
}
})
}
//设置radiobuttonlist 选中的 value :
function SetRbtnListByEdValue(radiobuttonlistid, _val) {
$("#" + radiobuttonlistid + " input[value='" + _val + "']").attr("checked", "checked");
}
//设置radiobuttonlist 选中的 索引 :
function SetRbtnListByEdIndex(radiobuttonlistid, _selectedIndex) {
var tempThis;
var targetObj = $("#" + radiobuttonlistid + " input");
targetObj.each(function() {
tempThis = $(this);
if (targetObj.index(this) == _selectedIndex) {
tempThis.attr("checked", "checked"); return;
}
})
}