judetselect.php
Cod: Selectaţi tot
<body>
<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 fjudet(form) {
var req = Inint_AJAX();
Item = form1.categorie.selectedIndex;;
Result = form1.categorie.options[Item].text;
req.open("GET", "judete1.php?Result=" + Result);
req.onreadystatechange = function () {
if (req.readyState==4) {
alert(this.responseText);
}
}
req.send(null);
}
</SCRIPT>
<form name="form1">
<select id="categorie" name="categorie" "style="width: 202px" style="width: 170px" onchange="fjudet(this.form);">';
<?php include("judete1.php");?>
</select>
</form>
</body>
judete1.php
Cod: Selectaţi tot
<?php
$host = "localhost";
$utilizator = "root";
$parola = "";
$numebd = "proiect";
$con = mysql_connect($host, $utilizator, $parola);
if (!$con) {
echo 'Eroare la conectarea bazei de date.';
exit;
}
mysql_select_db($numebd, $con);
$res=mysql_query("select DISTINCTROW judet from judete order by judet ASC");
if(mysql_num_rows($res)==0) echo "there is no data in table..";
else
for($i=0;$i<mysql_num_rows($res);$i++) {
$row=mysql_fetch_assoc($res);
echo"<option>$row[judet]</option>";
}
echo $_GET['Result'];
?>
totul OK pana la echo $_GET['Result'] pt care imi da eroarea
"Notice: Undefined index: Result in C:\Program Files\EasyPHP-5.3.5.0\www\Proiect\judete1.php on line 23"
Hepl ! Ce nu-i bine in script, de ce nu transmite variabila result php-ului ...