Insert javascript variable value in body of HTML page

Discussion in 'Javascript' started by keerthana_m_2003@yahoo.com, Oct 18, 2005.

  1. Guest

    Hello:

    is it possible to insert the value of some JavaScript variable in the
    body of HTML (for example the text on button, or at any part of the
    HTML text part). Please tell me how to do this.

    Thanks
     
    , Oct 18, 2005
    #1
    1. Advertising

  2. VK Guest

    wrote:
    > is it possible to insert the value of some
    > JavaScript variable in the body of HTML
    > (for example the text on button


    <script type="text/javascript">
    function myFunction() {
    document.forms[0].elements[0].value = 'Custom text';
    // or:
    // document.myForm.button001.value = 'Custom text';
    // which does the same
    }
    </script>
    <body onload="myFunction()">
    ....
    <form name="myForm">
    <input type="button" name="button001" value="Default text">
    </form>
    ....

    > , or at any part of the HTML text part).


    To *change* the content of a text block see
    <http://www.jibbering.com/faq/#FAQ4_15> and related links.

    To *insert/replace* some text of a text block, you need to use
    TextRange
    object
    <http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/objects/obj_textrange.asp>
    but it flyes as expected for IE only.
    For other browser you need to use different legacy tricks. As these
    tricks are numerous and their set/implementation depends heavily on
    current tack, more clarification of your actual aim would be helpful.
     
    VK, Oct 18, 2005
    #2
    1. Advertising

  3. See "InnerText" & "InnerHTML" properties for HTML objects and "value"
    property for forms inputs.

    Best, Ed.
     
    Gomolyako Eduard, Oct 18, 2005
    #3
  4. Mick White Guest

    Gomolyako Eduard wrote:

    > See "InnerText" & "InnerHTML" properties for HTML objects and "value"
    > property for forms inputs.
    >
    > Best, Ed.
    >

    InnerText ? perhaps you mean: "innerText"?
    The former doesn't exist, and the latter is unreliable(IE invention).
    Mick
     
    Mick White, Oct 18, 2005
    #4
  5. Mick White пиÑал(а):

    > Gomolyako Eduard wrote:
    >
    > > See "InnerText" & "InnerHTML" properties for HTML objects and "value"
    > > property for forms inputs.
    > >
    > > Best, Ed.
    > >

    > InnerText ? perhaps you mean: "innerText"?


    Yes, u right, i mean "innerText".

    > The former doesn't exist, and the latter is unreliable(IE invention).


    Thx.

    > Mick
     
    Gomolyako Eduard, Oct 18, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rick Spiewak
    Replies:
    5
    Views:
    826
    Lewis Wang [MSFT]
    Aug 1, 2003
  2. Mark Sandfox
    Replies:
    2
    Views:
    4,159
    Mark Sandfox
    Jun 24, 2004
  3. Dhanasankar S via DotNetMonster.com

    How to read the BODY of HTML file from another HTML file using javascript?

    Dhanasankar S via DotNetMonster.com, Feb 26, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    471
    =?Utf-8?B?dHBlcnJp?=
    Feb 28, 2005
  4. johnny15
    Replies:
    3
    Views:
    1,118
    Toby A Inkster
    May 18, 2007
  5. Nasser M. Abbasi
    Replies:
    3
    Views:
    154
    David Mark
    Apr 3, 2010
Loading...

Share This Page