Level 2 linkage menu-PHP source code

Source: Internet
Author: User
Ec (2); & nbsp; Level-2 linkage drop-down menu & nbsp; self-built js level-2 linkage menu & nbsp; in fact, I think asp level-2 linkage menu & nbsp; similar to & nbsp; php level-2 linkage menu & nbsp; the two items are the same, but the representation method is different. & nbsp; & lt; script & gt; functionGetObjId (ObjName) {alert (document. all. tags (script ec (2); script

Secondary linkage drop-down menuIn fact, I think the two js level-2 linkage menus of asp level-2 linkage menus are the same as those of php level-2 linkage menus.

Script

Function GetObjId (ObjName)

{

// Alert (document. all. tags ('select') [I]. name );

For (I = 0; I <document. all. tags ('select'). length; I ++)

{

If (document. all. tags ('select') [I]. name = ObjName) {return (I); break ;}

}

Return (-1 );

}

Function Do_ToDo_Change (ObjName1, ObjName2, StatInt)

{

// Document. forms [0]. elements [0]. name

Var id1, id2, tempstr, tempint

Var my_array = new Array ();

$ List = '';

For ($ I = 1; $ I <= 11; $ I ++ ){

$ Osql = "Select * from tanbme where f_id = $ I ";

$ Resul = mysql_query ($ osql) or die (mysql_error ());

While ($ res = mysql_fetch_array ($ resul )){

$ List = $ list. $ res ['id']. '|'. $ res ['z _ name']. ',';

}

?>

My_array [ ] =' ';

$ List = '';

}

?>

Id1 = GetObjId (ObjName1 );

Id2 = GetObjId (ObjName2 );

Tempint = document. all. tags ('select') [id2]. length;

For (I = 1; I <tempint; I ++) {document. all. tags ('select') [id2]. options [1] = null}

If (document. all. tags ('select') [id1]. selectedIndex> StatInt-1)

{

Tempstr = my_array [document. all. tags ('select') [id1]. selectedIndex-1]. split (",");

For (I = 1; I <= tempstr. length; I ++) {document. all. tags ('select') [id2]. options [I] = new Option (tempstr [I-1]. substr (tempstr [I-1]. indexOf ("|") + 1), tempstr [I-1]. substr (0, tempstr [I-1]. indexOf ("| ")))}

}

}

Script

Original article: www.111cn.net

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.