The DropDownList of two-level linkage implemented by XMLHTTP

Source: Internet
Author: User
Tags count sql string split tostring
Xml

Users need to register in accordance with different user types, in the database to filter out different products available to the user. Think, the best effect can only be without the method of refreshing.

Front steps: (JS)

function Fillproduction ()
{
var dwl = document.all ("Dropdownlistlevel");
var HTP = new ActiveXObject ("Microsoft.XMLHTTP");
var url = "reg.aspx?fp=" + dwl.value; Htp.open ("POST", Url,false);
Htp.setrequestheader ("Content-type", "application/x-www-form-urlencoded") htp.send ();
var str = Htp.responsetext;
if (str!= "")
{
var MyData = Str.split ("$");
if (Mydata[0]!= 0)
{
for (Var i=1;i<=mydata[0];i++)
{
var tmp = Mydata[i].split ("@");
var item = new Option ();
Item.text = tmp[0] + "|" + tmp[1] + "BV";                        Item.value = tmp[2]; DOCUMENT.SUBMIT.DROPDWONLISTPRODUCTION.OPTIONS[I-1] = Item;
}
Document.submit.hidpid.value = Document.submit.DropDwonListProduction.value;
}
Else
{
var len = document.submit.DropDwonListProduction.options.length;
for (Var i=len-1;i>=0;i--)
{
Document.submit.DropDwonListProduction.options.remove (i);
}
Document.submit.hidpid.value = "";
}
}
HTP = null;
}

Background encoding:

private void Fillproduction ()
{
String sql;
sql = "Select Pgr_prod_descr,pgr_bv_value,pgr_prod_grp_cd from Prod_grp t where T.pgr_bv_value = (select DAL_BV from def_a Cct_level where dal_id = "+ request[" FP "] +") ";
DataTable DT;
DT = sqlhelper.filldatatable (sqlhelper.conn_string,commandtype.text,sql);
string tmp;
if (dt. Rows.Count >0)
{
TMP = dt. Rows.Count.ToString () + "$";
for (int i=0;i<=dt. rows.count-1;i++)
{
TMP = tmp + dt. Rows[i][0]. ToString () + "@" + dt. ROWS[I][1]. ToString () + "@" + dt. ROWS[I][2]. ToString () + "$";
}
}
Else
{
TMP = "0$";
}
Response.Write (TMP);
}



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.