Help - Search - Members - Calendar
Full Version: innerHTML in IE7 vs FF
HTMLHelp Forums > Programming > Client-side Scripting
kryles
Hi,

I have a select box for states/Provinces that is filled, and I want it to change according to the country chosen.

the JavaScript function is called (tested using alert() ), but in IE7 it fails at the following line

CODE

function check_country()
{
    var sel_country = document.getElementById("country");

    if(sel_country.value == "US")
    {
               <?php
        $query = "    SELECT stateName, stateAbbrev
                    FROM states
                    WHERE stateEnabled = '1'
                    ORDER BY stateName ASC";
        $result = mysql_query($query);

        $prov = "<select name=\"state\" id=\"state\" class=\"widthed\">";

        while($row = mysql_fetch_row($result))
        {
            $prov .= "<option value=\"$row[1]\">$row[0]</option>";
        }
        $prov .= "</select>";
        ?>
         document.getElementById("tab1").rows[2].cells[3].innerHTML = "*State:";
         document.getElementById("tab1").rows[3].cells[0].innerHTML = "*Zip Code:";
         document.getElementById("tab1").rows[2].cells[4].innerHTML = <?php echo $prov; ?>; //fails here
}


Notice the two lines above it work, which use getElement and innerHTML the same way. Could it be because it outputs a string not in quotes?

This works just fine in FF but fails at the specified line in IE

Thanks,

kryles
CODE
document.getElementById("tab1").rows[2].cells[4].innerHTML = '<?php echo $prov; ?>';


is the fix. I tried double quotes and not single

/embarrased
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.