TeamPhotoshop
Reviews, updates and in depth guides to your favourite mobile games - AppGamer.com
Forum Home Latest Posts Search Help Subscribe

dhtml + javascript text question

Page: 1 Reply
Apr 1st 2004#146940 Report
Member since: May 12th 2003
Posts: 143
can you change the text content of a div? i wrote a script that calculates the power supply a computer will need, and i want to display the outcome as text on the page.

the total watt count for the computer is stored in a variable, so is there some way to use writeLn() to a div?

for the sake of apperance i dont want to use an alert box or textarea, but i dont want to have to write a div for every possible outcome!
Reply with Quote Reply
Apr 1st 2004#146944 Report
Member since: Mar 20th 2001
Posts: 3367
Use javascript's document.write to where you wish to dynamically show the text. Should work
Reply with Quote Reply
Apr 1st 2004#146964 Report
Member since: May 12th 2003
Posts: 143
i thought of that, but i couldn't get the document.writeln() to work within the div tag. does anyone know how do do that?
Reply with Quote Reply
Apr 1st 2004#146967 Report
Member since: Mar 24th 2002
Posts: 3114
I don't know how supported innerHTML is in other browsers...I think IE, Opera, Netscape and Mozilla should support it. Don't know if you're familiar with it, but;

function writeCrapIntoDiv(content){
divname.innerHTML=content;
}

writeCrapIntoDiv("this would appear in the DIV with the name 'divname' in this case");

I'm very rusty when it comes to JS, but that should work?
Reply with Quote Reply
Apr 2nd 2004#147038 Report
Member since: May 12th 2003
Posts: 143
thanks paavo, asked this question at experts exchange too, got worthless s**t for answers over there, and you come up with a nice simple 3 lines of code that works. fantastic.
Reply with Quote Reply
Page: 1 Back to top
Please login or register above to post in this forum