Hi,
Can you explain your problem a bit more.... and provide snap of code which you are using......
However if you want to call the Ajax function on selected index change then obvious thing is that you need to call that function on second dropdown box's onchange event......
Regards,
RP
Hi,
Firstly thanks for the response. Ya,I need to call that function on second dropdown box's onchange event. But that second dropdown is dynamically coming from another page with fully populated thru HTML response and im getting it in the orginal page thru innerhtml. Any way im attaching the code below.Plzz check it out ...
Subtasklist.php (this is my main mage)
<html>
<body>
<SCRIPT LANGUAGE="JavaScript">
var xmlHttp;
function showtask(str)
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="gettask.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")
{
var s=document.getElementById('txttask'); //getting my div id here
var ss=xmlHttp.responseText;
document.getElementById('txttask').innerHTML=ss;
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
//Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
</script>
<table width="100%" align="center" cellpadding="0" cellspacing="0" bgcolor="#999999">
<form >
</table>
<table>
<tr>
<td>Projects:</td>
<td>
<select name=ddlproject onchange="showtask(this.value)" >
<option value=0>
<?php
echo "Select";
$query = "SELECT projectCode,projectName FROM projects";
$result = $d->query($query);
while($row = $d->fetch_array($result))
{
?>
<option value="<?php echo $row["projectCode"]?>">
<?php
echo $row["projectName"];
?>
</option>
<?php
}
?>
<?php
echo" </select>" ;
?>
</td>
<td>Task</td>
<td><table ><tr><td id="txttask"><select><option>select</option></select></td></tr></table></td>
</tr>
</table>
</form>
</body>
</html>
Gettask.php
( here is where im creating the new dropdown populated with some data)
<?php
require_once('include/config.php');
require_once('include/configClass.php');
echo"<table><tr><td>
<select name=ddl onchange='showsub(this.value)';>";
?>
<option value=0>
<?php
echo "Select";
$q=$_GET["q"];
$query="SELECT taskCode,taskName FROM phases WHERE projectCode = '".$q."'";
$result = $d->query($query);
while($row = $d->fetch_array($result))
{
?>
<option value="<?php echo $row["taskCode"]?>">
<?php
echo $row["taskName"];
?>
</option>
<?php
}
?>
<?php
echo" </select>" ;
?>
</td></tr></table>
This the way i tried. But what is the further procedure to list some data on the "onchange" event of this dynamically created dropdown. I think now you understand my problem...
Thanks