Results 1 to 2 of 2

Thread: storing a value in html

  1. #1
    Join Date
    Aug 2009
    Posts
    74
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default storing a value in html

    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
    }

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    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!
    Jeremy | jfein.net

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •