Hi again,Guys.Here's my problrm.

In Appointments.php ,In the Sector Drop down list when i select a sector,through AJAX i have selected the list of hospitals for the sector using fun1() and displayed it back here in appointsment.php.Now that's ok.
But when i try to acess the hospital select lists value in appointsment.php in fun() whose name i have defined as "place" in sectorhos.php it's not taking this value,probably because i have made the list in sectorhos.php rather than appointments.php

What's the solution?Is there a better way of doing this?

APPOINTSMENT.PHP

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
	<meta name="author" content="" />

	<title>Doctor Appointment Form</title>
<script language="javascript">
var xhr;
function fun()
{
try
{
    xhr = new ActiveXobject('Msxml2.XMLHTTP');

}
catch(e)
{
    try
    {
        xhr = new ActiveXObject('Microsoft.XMLHTTP');
    }
    catch(e2)
    {
        try{
            xhr = new XMLHttpRequest();
        } 
        catch(e3)
        {
            xhr = false;
        }
    }
}
xhr.onreadystatechange = function()
{
    if(xhr.readyState==4)
    {
        if(xhr.status==200)
        {   document.ajax.dyn.style.visibility='visible';
		    document.ajax.dyn.style.color='red';
            document.ajax.dyn.value=xhr.responseText;
            document.ajax.dyn1.value=$_SESSION['p'];
        }
        else
        { document.ajax.dyn.style.visibility='visible';
            document.ajax.dyn=xhr.status;

        }
    }
};
var x = document.getElementById('timefrom').value;
var y = document.getElementById('day').value;
var sector=document.getElementById('sector').value;
var avail=document.getElementById('avail').value;
var place=document.getElementById('place').value;
xhr.open("GET","appointcheck.php?d="+y+"&i="+x+"&s="+sector+"&p="+place+"&avail="+avail,true);
xhr.send(null);
}

function fun1()
{ 
try
{
    xhr = new ActiveXobject('Msxml2.XMLHTTP');

}
catch(e)
{
    try
    {
        xhr = new ActiveXObject('Microsoft.XMLHTTP');
    }
    catch(e2)
    {
        try{
            xhr = new XMLHttpRequest();
        } 
        catch(e3)
        {
            xhr = false;
        }
    }
}
xhr.onreadystatechange = function()
{
    if(xhr.readyState==4)
    {
        if(xhr.status==200)
		
        {  
 //var a=d.options[d.options.selectedIndex].text;
 

		
		
		
		    document.getElementById("hosdiv").innerHTML=xhr.responseText;
			
            
        }
        else
        { document.getElementById("hosdiv").innerHTML=xhr.status;

        }
    }
};
var sector = document.getElementById('sector').value;

xhr.open("GET","sectorhos.php?sec="+sector,true);
xhr.send(null);
}

</script>

</head>

<link rel="stylesheet" href="experimentcss.css" />
<body>
<table width="1100" height="800" border="1" cellpadding="0" cellspacing="0" align="center" >

  <!----1ST ROW OF MAIN TABLE---->

<tr>
<td><br />
  <?php session_start();?>
<form name="ajax" action="appointcheck.php" method="get">
<table cellpadding="10" cellspacing="10" align="center">
<caption>FILL YOUR APPOINTMENT TIMINGS FOR NEXT WEEK HERE</caption>
<tr><td>SECTOR</td><td>:<select  id="sector" name="sector" onchange="fun1()"><option value="sector-1">SECTOR-1</option>
 <option value="sector-2">SECTOR-2</option>
 <option value="sector-3">SECTOR-3</option>
 <option value="sector-4">SECTOR-4</option>
 <option value="sector-5">SECTOR-5</option>
 <option value="sector-6">SECTOR-6</option>
 <option value="sector-7">SECTOR-7</option>
 <option value="sector-8">SECTOR-8</option>
 <option value="sector-9">SECTOR-9</option>
 <option value="sector-10">SECTOR-10</option>
 </select></td></tr>
<tr><td>DAY</td><td>:<select id="day" name="day"><option value="monday">Monday</option>
<option value="tuesday">Tuesday</option>
<option value="wednesday">Wednesday</option>
<option value="thursday">Thursday</option>
<option value="friday">Friday</option>
<option value="saturday">Saturday</option>
<option value="sunday">Sunday</option>
</select></td></tr>
<tr><td>TIME FROM</td><td>:<select id="timefrom" name="timefrom">
 <option value="8">08:00</option>
 <option value="9">09:00</option>
 <option value="10">10:00</option>
 <option value="11">11:00</option>
 <option value="12">12:00</option>
 <option value="13">13:00</option>
 <option value="14">14:00</option>
 <option value="15">15:00</option>
 <option value="16">16:00</option>
 <option value="17">17:00</option>
 <option value="18">18:00</option>
 <option value="19">19:00</option>
 <option value="20">20:00</option>
 </select></td></tr>
<tr><td>AVAILABILITY</td><td>:<select id="avail" name="avail"><option value="1">1 hrs.</option>
<option value="2">2 hrs.</option>
<option value="3">3 hrs.</option>
<option value="4">4 hrs.</option>
</select></td></tr>
<tr><td>PLACE</td><td>:<div id="hosdiv"></div></td></tr>
</table>
<center><input type="button" name="submit" value="SUBMIT"  onclick="fun()" style="background-color: aqua;" /></center><br />
<center><input type="text" name="dyn" style="visibility:hidden;border:hidden"/></center>

</form>
<br>
</td>
</tr>

SECTORHOS.PHP

<?php
session_start();
$sector=$_GET['sec'];

/*$sector="sector-2";*/
$link=mysql_connect("localhost",'root','') or die("server not connected");
$db=mysql_select_db("gmd") or die("db not selected");
$qr="select hospitals from sechos where sector='$sector'";
$result=mysql_query($qr,$link);

?>

<select name="place" >

<?php while($row=mysql_fetch_array($result)) { ?>
<option value="<?php echo $row['hospitals']; ?>"><?php echo $row['hospitals']; ?> </option>
<?php } ?>
</select>

What value are you meaning ? This one $sector=$_GET['sec']; ?
Your question is not clear.

@zero13

THANK YOU very much sir,although u didn't directly answer my Question but ur Question above made me Realize my Absolutely Silly mistake.
i wasn't able to get the value of

var place=document.getElementById('place').value;

I thought it's because i had defined place in Sechos.php and am retreiving in appointsment.php But the Real problem/Mistake was that i defined 'place' as Name and not ID in sechos.php
Silly Me :)

ႊႊThen, it solved ? If so, mark as Solved with below link.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.