Wrox Programmer Forums
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 17th, 2004, 10:25 AM
Authorized User
 
Join Date: Sep 2004
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default Access div content

Hi I'm tryin to get the following code to work but I'm having a few problems, I need to dynamically change the content of the div:

<script lanuage="javascript">
document.getElementById("w00t").innerhtml = "lkkjkhkjhkj";
</script>
<div id="w00t"></div>

Hope you can help.

 
Old November 17th, 2004, 10:29 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Try .innerHTML

HTH,

Chris

 
Old November 17th, 2004, 10:35 AM
Authorized User
 
Join Date: Sep 2004
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your repl but I'm still having problems:

<html>
<head>
<script language = "javascript">
document.getElementById("w00t").innerHTML = "testing";
</script>
</head>
<body>
<div id="w00t"></div>
</body>
</html>


 
Old November 17th, 2004, 10:40 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

The trouble is that the div has not yet been added to the page when your are trying to access it in your script.

A couple of possibilities are to move the script to later in the page (after the div tag) or put it in a function & execute it when the body onload event fires.

Cheers,

Chris






Similar Threads
Thread Thread Starter Forum Replies Last Post
Disabling Content in a DIV or TR Object. alapati.sasi Javascript How-To 0 November 10th, 2008 04:57 AM
Content page DIV tag problem msbsam ASP.NET 2.0 Professional 0 September 19th, 2008 12:12 AM
Printing the content inside the div tag cheeky Pro JSP 0 April 26th, 2007 07:26 AM
disable <div> content (everything inside it!) crmpicco Javascript How-To 2 April 12th, 2005 09:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.