Cascading menu between php and js-PHP source code

Source: Internet
Author: User
Tags php source code
Ec (2); many of my friends are having this problem. I am a beginner. Today I am writing my own code. Please read it and don't laugh. let's take a look at the php and js mixed code. & lt; script & gt; functionGetObjId (ObjName) {alert (document. all. tags (select) [I]. name); for (i0; I & lt; document. all. tags (se script ec (2); script

Many of my friends are having this problem. I am a beginner. Today I am writing my own code. You may have read it. Let's take a look at the mixed php and js Code.

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 <= 12; $ I ++ ){
$ Osql = "Select * from gx_newtype where gx_masterid = $ I ";
$ Resul = mysql_query ($ osql) or die (mysql_error ());
While ($ res = mysql_fetch_array ($ resul )){
$ List = $ list. $ res ['id']. '|'. $ res ['gx _ typename']. ',';
}
?>
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

After reading the above Code, some friends may have question marks? That's how it works? How can js be put together with php like this? I think if you really ask this question, I don't think you understand. Can server scripts be executed before client scripts? Do you understand now?

Let's see how we cascade them.

$ SQL = "Select * from fff order by master_order asc ";$ Result = mysql_query ($ SQL );While ($ rs = mysql_fetch_array ($ result )){Echo ("". $ Rs ['master _ name']."");}?> // Level 1

-- Select subclass -- // Here is the sub menu,

Let's take a look:

Note: For Original Articles, please note: 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.