Who can write a 2-level interactive select example? let's look at a simple example. write a comment and study it. thanks to you, functioncollege2subject (collegeid) {varallcount = 0; subjectArray = newArray (); & lt ;? Php $ link = my, who can write an example of two-level linkage select?
Write a simple example and write a comment to study it. thank you for your attention.
------ Solution --------------------
Function college2subject (collegeid)
{
Var allcount = 0;
SubjectArray = new Array ();
$ Link = mysql_connect ("localhost", "root", "123 ");
$ Db_selected = mysql_select_db ("test ");
Mysql_query ("set names utf8 ");
$ SQL = "select * from subject ";
$ Result = mysql_query ($ SQL );
$ Count = 0;
While ($ myrow = mysql_fetch_array ($ result ))
{
Echo "subjectArray [". $ count. "] = new Array ('". $ myrow ['subject _ id']. "','". $ myrow ['subject _ name']. "',
'". $ Myrow ['College _ id']."') \ n ";
$ Count ++;
}
Echo "allcount = $ count ;";
?>
Document. studentform. subject. length = 0;
Document. studentform. subject. options [document. studentform. subject. length] = new Option ("all major ","");
Var college_id = collegeid;
Var I;
For (I = 0; I {
If (subjectArray [I] [2] = college_id)
{
Document. studentform. subject. options [document. studentform. subject. length] = new Opiton (subjectArray [I] [1], subjectArray [I] [0]);
Alert ("OK ");
}
}
}
Alert ("OK ");
Script
$ Link = mysql_connect ("localhost", "root", "123 ");
$ Db_selected = mysql_select_db ("test ");
Mysql_query ("set names utf8 ");
$ SQL = "select * from college ";
$ Result = mysql_query ($ SQL) or die (mysql_error ());
?>
| Select School |
All schools While ($ myrow1 = mysql_fetch_array ($ result )){?> "Selected =" selected "> ------ Solution --------------------Select filter _ waterPlate Select Water1 Water2 Water3 Water4 Water5
Level 2 Select Water5-5 Water5-6 |