tags:

views:

25

answers:

1

Hey guys,

For some reason, I can't change the contents of a DIV in either IE or Firefox. Any ideas where I might be going wrong?

JavaScript

function displayTable() {
 document.getElementById('retailerDiv').innerHTML = '<a>HEY!</a>';
}

HTML

<input type="text" id="userQuery" onkeydown="displayTable()"/>
<br/>
<div id="retailerDiv">
Now
</div>
A: 

The code you posted works fine. Perhaps edit and post all of your source, or link to your page on the web. I don't have any problems with this working in Firefox 3.5 or IE8:

<HTML>
<HEAD>
    <script type="text/javascript">
        function displayTable() 
        {
            document.getElementById('retailerDiv').innerHTML = '<a>HEY!</a>';
        }
    </script>
</HEAD>
<BODY>
    <input type="text" id="userQuery" onkeydown="displayTable()"/>
    <br/>
    <div id="retailerDiv">
        Now
    </div>
</BODY>
</HTML>
Rob
Ah, apologies. It seems that I had incrrectly typed my comment syntax and it wasn't being properly excluded from execution. Thanks a lot for your help, much appreciated!
Phil Williams
Not a problem, those things happen. Glad I could help!
Rob