Home > Web Front-end > JS Tutorial > Discussion on jQuery JSON implementation of three-level linkage without refreshment_jquery

Discussion on jQuery JSON implementation of three-level linkage without refreshment_jquery

WBOY
Release: 2016-05-16 17:32:57
Original
1113 people have browsed it
复制代码 代码如下:





js:
复制代码 代码如下:




LoadClass.ashx:
复制代码 代码如下:

<%@ WebHandler Language="C#" Class="LoadClass" %>
using System;
using System.Web;
using System.Text;
using System.Data;
public class LoadClass : IHttpHandler {
public void ProcessRequest (HttpContext context) {
// 数组 [{"ID":"275","Cname":"A1"},{"ID":"319","Cname":"A2"},{"ID":"322","Cname":"A3"}]
int strId = Convert.ToInt32(context.Request["ddlId"]);
string strSQL = "select * from Class where parent_Ptr=" strId " order by classOrder asc ";
db d = new db();
DataTable dt = d.getDT(strSQL);
StringBuilder strClass = new StringBuilder();
if (dt != null)
{
strClass.Append("[");
for (int i = 0; i < dt.Rows.Count; i )
{
strClass.Append("{");
strClass.Append(""ID":"" dt.Rows[i]["id"].ToString() "",");
strClass.Append(""Cname":"" dt.Rows[i]["classCname"].ToString() """);
if (i != dt.Rows.Count - 1)
{
strClass.Append("},");
}
}
}
strClass.Append("}");
strClass.Append("]");
context.Response.ContentType = "application/json";
context.Response.ContentEncoding = Encoding.UTF8;
context.Response.Write(strClass.ToString());
context.Response.End();
}
public bool IsReusable {
get {
return false;
}
}
}

注意:
复制代码 代码如下:

//The background can only get the value value, not the text directly, it needs to be transferred through js and control
//Result: 275 276 277
Label1.Text = Request.Form[ddl1.UniqueID ] " " Request.Form["ddl2"] " " Request.Form[ddl3.ClientID.Replace("_", "$")] ;Problems encountered: The value of the drop-down box text is transferred through the HiddenField control


Assign the value of the selected drop-down box to the hidden control:

After selecting the drop-down box, the value dynamically assigned to the HiddenField control cannot correspond to the value selected in the drop-down box!
It may be related to initialization. Where should the assignment code be placed? Or is there any good method? Welcome to discuss?
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template