<script language = "javascript">
var XMLHttpRequestObject = false;
if (window.XMLHttpRequest) {
XMLHttpRequestObject = new XMLHttpRequest();
} else if (window.ActiveXObject) {
XMLHttpRequestObject = new
ActiveXObject("Microsoft.XMLHTTP");
}
function getData(dataSource, divID)
{
if(XMLHttpRequestObject) {
var obj = document.getElementById(divID);
XMLHttpRequestObject.open("GET", dataSource);
XMLHttpRequestObject.onreadystatechange = function()
{
if (XMLHttpRequestObject.readyState == 4 &&
XMLHttpRequestObject.status == 200) {
obj.innerHTML =
XMLHttpRequestObject.responseText;
}
}
XMLHttpRequestObject.send(null);
}
}
</script>
Here I call the ajax fuction on post.php :
<tr>
<td colspan="2" width="250">Choose Subject: <select onchange="getData('post2.php?data='+this.value,
'[B]mydiv[/B]')" style="width:250px; height:25px; margin-left:5px" name="sub">
<?php
include('db.php');
$queryn=mysql_query("SELECT * FROM `subjects`");
echo "<option value=none>=========Select=========</option>";
while($rown=mysql_fetch_row($queryn))
{
echo "<option value=$rown[0]>$rown[1]</option>";
}
?>
</select></td>
</tr
>
Here is the blank div where fetched data will be appeared
<tr>
<td colspan="2" width="400"><div id="fake" style="float:left"> Choose Mother Topic: </div> <div id="[B]mydiv[/B]" style="float:left"> </div>
</td>
</tr>
And here is the post2.php for
<?php
$sub=$_GET['data'];
include('db.php');
$run=mysql_query("SELECT * from mother_topics where s_id='$sub'");
echo "<select style=width:400px; height:25px; margin-left:5px name=mt>";
while($rows=mysql_fetch_row($run))
{
echo "<option value=$rows[0]>$rows[2]</option>";
}
echo "</select>";
?>
It works fine and as soon as I change the subject, a dropdown menu appears on mydiv.Pretty fine but when I'm submitting this form and trying to retrieve the value of select name=mt with $var=$_POST; on post.php its cant receive anything!! I need to find a way...please help.
If you still didnt get what Im talking about then go to techysafi.co.cc/login.php and use df and sdf as username and password(dummy), after login go to techysafi.co.cc/post.php .
Thanks