need help on innerHTML

This is a discussion on "need help on innerHTML" within the JavaScript Forum section. This forum, and the thread "need help on innerHTML are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Dec 1st, 2007, 03:07
Junior Member
Join Date: Nov 2007
Location: Hong Kong
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
need help on innerHTML

i've been trying to print some message in <div id="information">
these messages were stored in the var info

here's the html code
HTML: Select all
<body><div id="hello">Hello!</div>
<div id="infromation"></div>
</body>
and the JS
Code: Select all
var whatisthis = window.location.href.split("/");
var last= whatisthis.length -1;
var nohtml = whatisthis[last].split(".");
last = nohtml.length -2;
var info = "<h3>Title: </h3>" + "<p> Tutorial " + nohtml[last] + "</p>";

document.getElementById("information").innerHTML = document.write(info);
at the moment nothing could be printed
if i change the last line to document.write(info);
i get the message that i want though it is not printed inside the information div

How can i get those message to be printed in specific div??
thx!

Last edited by karinne; Dec 3rd, 2007 at 14:35. Reason: Please use vBcode when inserting code in your post.
Reply With Quote

  #2 (permalink)  
Old Dec 1st, 2007, 03:35
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: need help on innerHTML

change the last line to

document.getElementById("information").innerHTML = info;

You don't need to use document.write to add to innerHTML, you just use the value you want added.

document.write tries to destroy the page and start a new one.

Cheers
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Reply With Quote
  #3 (permalink)  
Old Dec 1st, 2007, 03:52
Junior Member
Join Date: Nov 2007
Location: Hong Kong
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Re: need help on innerHTML

Thank you very much!

i've followed your advice and changed the last line
there's a new problem though. the ";" didn't seem to end the operation of
document.getElementById("information").innerHTML = info;

an error cascades downward from thereon and other functions after this line could not be run.
what went wrong this time?
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
innerHtml doesn't retrive the formatting from DIV shamail ASP.NET Forum 0 Aug 24th, 2007 20:02
Changing innerHTML not really working in IE Zonglars JavaScript Forum 2 Jul 26th, 2007 20:31
innerHTML and innerHTML match DregondRahl JavaScript Forum 2 Jun 11th, 2007 13:24
how to use innerHTML for preview in Kevin Roth's rte mel03 JavaScript Forum 2 Dec 22nd, 2006 12:15
innerHTML in IE TheDC JavaScript Forum 6 Oct 30th, 2006 21:18


All times are GMT. The time now is 04:45.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43