i am using dropdown for classes. so when user will select a particular class then it will display subjects in the same page based on class from database.
i am giving my code along with so please tell me the error.
code for database
Expand|Select|Wrap|Line Numbers
- <?php
- include "database.php";
- $class1= $_GET['q'];
- $selectclass= "SELECT Subjects FROM subjects WHERE Class= '$class1'";
- $query=mysql_query($selectclass);
- echo "<table>";
- echo"<tr>";
- echo"<th> Subjects</th><th>Marks</th></tr>";
- while($rows=mysql_fetch_array($query))
- {
- echo "<tr>";
- echo "<td>";
- echo $rows['Subjects'];
- echo "</td>";
- echo "<td>";
- echo "<input type= text/>";
- echo "</td>";
- echo "</tr>";
- }
- echo "</table>";
- ?>
Expand|Select|Wrap|Line Numbers
- var xmlHttp;
- function selectClass(str)
- {
- alert(str);
- xmlHttp=GetXmlHttpObject()
- if(xmlHttp==null)
- {
- alert("Error");
- return
- }
- var url="getsubject.php";
- url=url+"?q"=str;
- //url=url+"&sid="+Math.random();
- xmlHttp.onreadystatechange=stateChanged
- xmlHttp.open("GET",url,true)
- xmlHttp.send(null)
- }
- function stateChanged()
- {
- if (xmlHttp.readyState==4|| xmlHttp.readyState=="complete")
- {
- document.getElementById("txtselect").innerHTML=xmlHttp.responseText;
- }
- }
- function GetXmlHttpObject()
- {
- var xmlHttp=null;
- try
- {
- xmlHttp=new XMLHttpRequest();
- }
- catch (e)
- {
- try
- {
- xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
- }
- catch (e)
- {
- xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
- }
- }
- return xmlHttp
- }
but value is not coming and not showing any error as well..I think the value for $class1 is not coming that's why it is showing nothing.
please help me out.