English 中文(简体)
支离破碎的发射场值
原标题:send fieldset values by jquery

研究了这一法典:

[WebMethod]
public static string GetFacilities(string id)
{
    int hotelid = System.Convert.ToInt32(Tools.DecryptString(id));

    string ret = "";

    foreach (var item in new FacilityGroupBL().Load())
    {
        if(item.Facilities.Count != 0)
        {
            ret += "<fieldset>";
            if (item.Facilities.Count() != 0)
            {
                foreach (var subitem in item.Facilities)
                {
                    if (subitem.HotelFacilities.Where(obj => obj.HotelId == hotelid).Count() != 0)
                        ret += "<input type= checkbox  checked= false  />" + subitem.Name;
                    else
                        ret += "<input type= checkbox  checked= true  />" + subitem.Name;
                }
            }
            else
            {
                ret += "There is no facility in this fieldset.";
                ret += "</fieldset>";
            }
        }
    }

    return ret;

}

该法典将一些检查箱装入DIV,用户更换一些检查箱,并出版SAVE纽顿。 此时,即应将这些检查箱的数值发送给服务器,以更新我在数据库中的数据。 (一) 如何? 帮助

note: my default code for this probem is here but it does not work($("#FacilitiesDIV input[type=checkbox]").serializeArray() is empty)

$.ajax({
    type: "POST",
    url: "HotelsList.aspx/SaveFacilities",
    data: "{  id  :  " + $("#HiddenField").val() + " ,  Facilities  :  " + $("#FacilitiesDIV input[type=checkbox]").serializeArray() + "  }",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (data) {

    },
    error: function () {
        $( #dialogMessage ).dialog( open );
        $( #dialogMessage span ).html("Operation Error");
    }
});
最佳回答

$("#FacilitiesDIV input[type=checkbox]").serializeArray() since you are referring element using "#" then you need to give the fieldset element an Unique ID assuming you have html like

 <fieldset>  <input type= checkbox  checked= false  /> some text
             <input type= checkbox  checked= false  /> some text 
    </fieldset>

set the id to element <fieldset id =  FacilitiesDIV >
问题回答

我认为,如果你给每个检查箱一个名字,即:

<input type= checkbox  checked= false  name="mycheckboxes" />




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签