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