如何将html里一组radio里选中的值传递到一般处理程序?
求大神解答! --------------------编程问答-------------------- 在ashx中, context.Request["Name"]不行吗? --------------------编程问答-------------------- $(function () {$("#BtnData").click(function () {
if ($('input[name="radio"]:checked').length < 1) {
alert("请选择!");
return;
}
var SapNumbers = "";
var i = 0;
$('input[name="radio"]').each(function (index, item) {
if (item.checked) {
SapNumbers += $(item).val()+"&";
}
});
$.post("Handler/DataHandler.ashx", { "SapNumbers": SapNumbers }, function (data) {
alert(data);
});
});
});
传过去的是一个字符串,你可以用字符串分割来把它们取到变成数组;
string SapNumbers = context.Request.Form["SapNumbers"];
string[] saps = SapNumbers.Substring(0, SapNumbers.Length - 1).Split('&'); --------------------编程问答-------------------- ajax传到ashx 然后request.form --------------------编程问答-------------------- Refer:
http://www.cnblogs.com/insus/archive/2012/11/12/2766488.html --------------------编程问答-------------------- js ajax 传人。 --------------------编程问答--------------------
正解 --------------------编程问答--------------------
//==========================================radiobuttonlist操作 Start=======================================
//获取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;
}
})
}
//==========================================radiobuttonlist操作 End=========================================
//==========================================checkboxlist操作 Start=========================================
//获取checkboxlist选中项的Text值集合
function GetChkListByEdText(chklistid) {
var item = $("#" + chklistid + " :input:checked").map(function() {
return $(this).next("label").text();
}).get().join(",");
return item;
}
//获取checkboxlist选中项的索引集合
function GetChkListByEdIndex(chklistid) {
var item = $("#" + chklistid + " :input:checked").map(function() {
var objThis = $(this);
return $("#" + chklistid + " :input").index(objThis);
}).get().join(",");
return item;
}
//==========================================checkboxlist操作 End=========================================
补充:.NET技术 , ASP.NET