<Script language = 'javascript 'Type = 'text/JavaScript '>
Function initajax () // initialize the Ajax object
{
// Return "adfasd ";
VaR Ajax = false;
Try {
Ajax = new activexobject ("msxml2.xmlhttp ");
} Catch (e ){
Try {
Ajax = new activexobject ("Microsoft. XMLHTTP ");
} Catch (e ){
Ajax = false;
}
}
If (! Ajax & typeof XMLHttpRequest! = 'Undefined '){
Ajax = new XMLHttpRequest ();
}
Return Ajax;
}
</SCRIPT>
//////////////////////////////////////// //////////////////////////////////////// ////////////////////////////////////
<Select name = "typeid" id = "typeid" onchange = "getch1_type ();">
<Option value = "-1"> merchant type </option>
<? Foreach ($ type as $ v) {?>
<Option value = "<? = $ V [linkageid]?> "> <? = $ V ['name']?> </Option>
<? }?>
</SELECT> </span> <span id = "show"> </span>
//////////////////////////////////////// //////////////////////////////////////// ///////////////////////////////////////
<SCRIPT>
Function getchlidtype ()
{
// URL for Ajax
VaR pid = Document. getelementbyid ("typeid ");
VaR url = "http: // 192.168.0.102/youyuanhui_com/ajax/getoption. php? PID = "+ PID. value;
// Obtain the position of the news display Layer
VaR show = Document. getelementbyid ("show ");
// Instantiate an Ajax object
VaR Ajax = initajax ();
// GET requests
Ajax. Open ("get", URL, true );
// Obtain the execution status
Ajax. onreadystatechange = function (){
// If the execution is normal, the returned content is assigned to the layer specified above.
If (Ajax. readystate = 4 & Ajax. Status = 200 ){
Show. innerhtml = Ajax. responsetext;
}
}
// Sending Blank
Ajax. Send (null );
}
</SCRIPT>
//////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// ////////////////////////////////////////
Getoption. php
<? PHP
Require '../include/common. Inc. php ';
Require '../include/system_info.php ';
Global $ dB;
If ($ pid = $ _ Get ["PID"])
{
$ Options = $ db-> select ("select * From yyh_linkage where parentid =". $ PID );
Echo "<select name = 'typeid2' id = 'typeid2'> ";
Echo "<option value = '-1'>-select subclass </option> ";
Foreach ($ options as $ OPT)
{
Echo "<option value =". $ OPT ['linkageid']. ">". $ OPT ['name']. "</option> ";
}
Echo "</SELECT> ";
}
?>
Principle: assume A and B have two pages.
Page A is an Ajax request. To display data information on page A, page a requests page B through Ajax, and page B displays the corresponding data on page B after obtaining the data, the content of page B is returned to page.