The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> innerHTML in IE7 vs FF, working fine in FF but not IE
kryles
post Jan 16 2008, 10:32 AM
Post #1


Novice
**

Group: Members
Posts: 21
Joined: 30-November 07
Member No.: 4,437



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,

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
kryles
post Jan 16 2008, 01:54 PM
Post #2


Novice
**

Group: Members
Posts: 21
Joined: 30-November 07
Member No.: 4,437



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


is the fix. I tried double quotes and not single

/embarrased
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th April 2024 - 08:34 AM