todayme Posted October 10, 2007 Share Posted October 10, 2007 I have 2 pages all the code works until I try to do the third item, please help solve this. First Page <? //set IE read from page only not read from cache header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header ("Cache-Control: no-cache, must-revalidate"); header ("Pragma: no-cache"); header("content-type: application/x-javascript; charset=tis-620"); $data=$_GET['data']; $val=$_GET['val']; //set database $dbhost = "localhost"; $dbuser = "333"; $dbpass = "333"; $dbname = "333"; mysql_pconnect($dbhost,$dbuser,$dbpass) or die ("Unable to connect to MySQL server"); if ($data=='states') { // first dropdown echo "<select name='states' onChange=\"dochange('cities', this.value)\">\n"; echo "<option value='0'>==== Please Select ====</option>\n"; $result=mysql_db_query($dbname,"select `id`, `state` from states order by `state`"); while(list($id, $name)=mysql_fetch_array($result)){ echo "<option value=\"$id\" >$name</option> \n" ; } } else if ($data=='cities') { // second dropdown echo "<select name='cities' onChange=\"dochange('profile', this.value)\"> \n"; echo "<option value='0'>==== Select Industry ====</option> \n"; $result=mysql_db_query($dbname,"SELECT `id`, `city` FROM cities WHERE `state_id` = '$val' ORDER BY `city` "); while(list($id, $name)=mysql_fetch_array($result)){ echo "<option value=\"$name\" >$name</option> \n" ; } } echo "</select>\n"; ************************************************************************* ************************************************************************ [b]THIS CODE BELOW IS RELATED TO THE OTHER PAGE THIS IS WHERE I AM HAVING A PROBLEM[/b] if ($data=='profile') { $result2=mysql_db_query($dbname,"SELECT `Profile` FROM _Industries WHERE `Industry` = '$name' "); echo "$result2 \n" ; } *************************************************************************** ?> <? echo "<form name=Leads>\n"; echo "<font id=states><select>\n"; echo "<option value='0'>============</option> \n" ; echo "</select></font>\n"; echo "<br>\n"; echo "<br>\n"; echo "<font id=cities name=cities><select> \n"; echo "<option value='0'>=== none ===</option> \n" ; echo "</select></font>\n"; BELOW IS RELATED TO THE FIRST PAGE BETEWEEN THE TWO THERE IS A PROBLEM PLEASE CAN SOMEONE HELP *************************************************************************** *************************************************************************** //echo "<font id=profile>\n"; echo "<div id=profile> </div>\n"; ***************************************************************************** ?> <script language=Javascript> function Inint_AJAX() { try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {} //IE try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} //IE try { return new XMLHttpRequest(); } catch(e) {} //Native Javascript alert("XMLHttpRequest not supported"); return null; }; function dochange(src, val) { var req = Inint_AJAX(); req.onreadystatechange = function () { if (req.readyState==4) { if (req.status==200) { document.getElementById(src).innerHTML=req.responseText; //retuen value } } }; req.open("GET", "state.php?data="+src+"&val="+val); //make connection req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); // set Header req.send(null); //send value } window.onLoad=dochange('states', -1); // value in first dropdown </script> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.