PDA

View Full Version : storing a value in html



hemi
07-02-2010, 06:44 AM
Hi All,

can i have a javascript value to be stored in html.what exactly i need is suppose
iam declaring like this in JavaScript

var abc = " ";

function sample()
{

// by somehow i am getting this "str" a value i.e.,
str=<pre>sssss</pre>.

// now can i use this string to be passed into div like this


abc = "<html><body><div id=one>"+ str + "</div></body></html>";

alert(abc);
// that means now in alert i should get only "sssss" not "<html><body><div id=one>"+ str + "</div></body></html>". When i am trying like this it is not working for me.
Is there a way?

I dont want this by Document.Write. I want that value to be stored in "abc", not to be printed
}

Nile
07-02-2010, 11:03 PM
You can't alert HTML. Are you trying to just change the html of something in javascript or actually alert HTML? If you're trying to change the html in javascript, take a look at https://developer.mozilla.org/en/DOM/element.innerHTML
or search Javascript innter html

Good luck!