hi... i'm a new member of daniweb

i have a problem in setting 2 comboboxes.
i want to populate the second combobox based on first combobox value.

i already have the code running well in firefox and chrome.
but the code is not working in IE.

can anyone please help me?
Thanx.

Hard to guess what's wrong without your HTML/Javascript code, or a link to your page.

this is my code..

<script>
function checkprovince()
{
    var province=document.getElementById("province").value;
    var xmlhttp;

    if(window.XMLHttpRequest)
    {
        xmlhttp=new window.XMLHttpRequest();

    }
    else
    {
        xmlhttp=new ActiveXObject("Microsoft.XMLTTP");
    }

    xmlhttp.onreadystatechange=function()
    {
        if(xmlhttp.readyState == 4 && xmlhttp.status ==200)
        {
            document.getElementById("city").innerHTML= xmlhttp.responseText;
        }
    }

    xmlhttp.open("POST","file.php",false);
    xmlhttp.setRequestHeader("content-type","application/x-www-form-urlencoded");
    xmlhttp.send("province="+province);
}
</script>

<select name="province" id="province" onchange="checkprovince()">
<option value=0 selected="selected">-choose province-</option>
<?php
$getprovince=mysql_query("select * from city, province where city.id_prov=province.id_prov group by province.id_prov") or die("error");
$row=mysql_num_rows($getprovince);

for($x=0;$x<$row;$x++)
{
    $provincename=mysql_result($getprovince,$x,"province_name");
    $idprov=mysql_result($getprovince,$x,"id_prov");
    print "<option value=$idprov>$provincename</option>"; 
}
?>
</select>
<select id="city" name="city" onfocus="checkprovince()">
<option value="0" selected="selected">-choose city-</option>
</select>

then in file.php

<?php
if(isset($_POST["province"]))
{
    $provinsi=$_POST["province"];
    include("config/koneksi.php");
    $getcity=mysql_query("select * from city where id_prov='".$province."'");
    $row=mysql_num_rows($getcity);
    print "<option value=0 selected='selected'>-choose city-</option>";
    for($x=0;$x<$row;$x++)
    {
        $idcity=mysql_result($getcity,$x,"id_city");
        $cityname=mysql_result($getcity,$x,"city_name");
        print "<option value=$idcity>$cityname</option>";

    }

}

?>

Line 14 has a typo, it's XMLHTTP.

it's still not working in IE...
i'm using IE 8

i tried to put window.alert below line 14, and it didn't come out also

Have you tried this: xmlhttp = new XMLHttpRequest();

thanx pritaeas..
but i already fixed it with another method..

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.