• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Error using .innerHTML in javascript

 
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am getting unknown run time error while using document.getElementById('test').innerHTML .........i wanted to change the text inside a label tag .my code looks like this

& lt;SCRIPT LANGUAGE="JavaScript">
function test()
{
alert("inside");
alert(document.getElementById("test").innerHTML);
document.getElementById('test').innerHTML = "hjsdhjsd";
}
& lt;/SCRIPT>
& lt;TABLE>
& lt;TR>
& lt;label id="test">& lt;TD>sdasdasd& lt;/TD>& lt;/label>
& lt;/TR>
& lt;/TABLE>
<INPUT TYPE="button" value="click" onick="test()">

onclick of the button i want to change the entire text inside that label tag ........i need to change even that <td> tag inside .........but this works fine if i use <span id'"test"> instead of a label component

can any one let me know the work around for this atleast
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can not have a tag inside a table that surrounds a cell. It should not render correct. IE will since it is bad, other browsers will not.

What are you trying to do exactly?

change the row?

Eric
 
sreenath reddy
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi eric

Thanks for ur reply . Actually inside that label i have a td with onmouseover and onmouseout events (Inside the td one image followed by label). Now as soon as i click the button i want to change that td to a simple one with out these 2 events

is there any other way of achieving that ??
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can remove the mouse events...

I think this should work:

document.getElementById("tdID").onmouseover = "";
document.getElementById("tdID").onmouseout = "";

Eric
 
What kind of corn soldier are you? And don't say "kernel" - that's only for this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic