hello,
i have java script below. i am retrieving states from mysql database and list them dropdown menu.
oscommerce, mysql and php.
this script works well when it is embedded between head tags to each php file in old version. goes to city_get.php and takes the state result from there. but in the new version (no head tags in php file) i saved the script as js file and try to call from template_top.php (which shows the all the java's way), explorer gives error in the below line. i have followed this error from explorer error messages.
getObject("states").innerHTML = req.responseText;
what is wrong with this?
thx
<?php
/*
$Id$
osCommerce, Open Source E-Commerce Solutions
osCommerce, Open Source Online Shop E-Commerce Solutions
Copyright © 2003 osCommerce
Released under the GNU General Public License
*/
?>
<script type="text/javascript"><!--
var req;
function loadXMLDoc(key) {
var url="city_get.php?ShptsiD=<?php echo tep_session_id();?>&country="+key;
getObject("states").innerHTML = ' <img style="vertical-align:middle" src="images/loading.gif"> Pls hold...';
try { req = new ActiveXObject("Msxml2.XMLHTTP"); }
catch(e) {
try { req = new ActiveXObject("Microsoft.XMLHTTP"); }
catch(oc) { req = null; }
}
if (!req && typeof XMLHttpRequest != "undefined") { req = new XMLHttpRequest(); }
if (req != null) {
req.onreadystatechange = processChange;
req.open("GET", url, true);
req.send(null);
}
}
function processChange() {
if (req.readyState == 4 && req.status == 200) {
getObject("states").innerHTML = req.responseText;
}
}
function getObject(name) {
var ns4 = (document.layers) ? true : false;
var w3c = (document.getElementById) ? true : false;
var ie4 = (document.all) ? true : false;
if (ns4) return eval('document.' + name);
if (w3c) return document.getElementById(name);
if (ie4) return eval('document.all.' + name);
return false;
}
//--></script>