views:

63

answers:

3

document.getElementById('grand_total_display).innerHTML = "Total is : $"+variable; is displaying error in IE6 and IE7

I have an <li>with id as grand_total_display with some text displayed in it.

<li class="bannerprice" id="grand_total_display">TOTAL PRICE : $0</li>

I am executing a jjavascript function to insert some other value into it.. but I am displayed with the error as given below: alt text

Please help me to rectify the issue

A: 

Make sure that your <script> is after the element #totaldisplay (also that the id is unique on your page).

galambalazs
There is no other element with same id
OM The Eternity
@galambalazs neither of the thing worked for me... :(
OM The Eternity
+1  A: 

Apparently there's no element in the DOM with 'totaldisplay' as its id, or, as galambalazs suggests, you might have multiple elements with the same id.

With IE7 you can use "Internet Explorer Developer Toolbar" and "Web Development Helper" plugin, to find the problem.

ncardeli
The IE Dev Toolbar does not have a JavaScript debugger.
Matt Ball
+1  A: 

You have the wrong ID:

variable = "howdy";
document.getElementById('grand_total_display').innerHTML = "Total is : $"+variable;

instead of

variable = "howdy";
document.getElementById('totaldisplay').innerHTML = "Total is : $"+variable;
Mark Schultheiss