我有下一个 jQuery 代码:
function getParameter() {
var valor = [];
$("input[name='TiposServicioSeleccionados']:checked").each(function (i) {
valor.push($(this).val());
});
if (valor.length == 0) {
valor.push("0");
}
return {
nofacturados: $("#nofacturados:checked").val(),
precioactual: $("#precioactual:checked").val(),
TiposServicioSeleccionados: valor
};
}
我想将 'valor' 授予 'TiposServicioSeleccionados',在我的控制器中我有这个
public ActionResult LeerExt_DevolucionRepuesto(string[] TiposServicioSeleccionados, bool? facturados, bool? nofacturados)
{
int id_empresaservicio = Convert.ToInt16(Session["id_empresaservicio"]);
var res = GetDevolucionRepuestos(TiposServicioSeleccionados,facturados,nofacturados);
return Json(res.ToDataSourceResult(request));
}
但TiposServicioSeleccionados总是为空,我不知道为什么......
我打电话getParameter
:
Read(read => read.Action("LeerExt_DevolucionRepuesto", "Consultas").Data("getParameter"))
我需要,例如,如果我选中了三个复选框,TiposServicioSeleccionados
我想保存下一个值:TiposServicioSeleccionados[0]="value of the first chekbox"
, TiposServicioSeleccionados[1]="value of the second chekbox"
,TiposServicioSeleccionados[2]="value of the third chekbox"
问候