SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2006
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Outputting Javascript in a label

    Is there a way of outputting a Javascript result in a label as well as it appearing in the standard alert pop up.

    eg. Have a normal Javascript alert saying "Hello" but also having it display in the window by placing a label perhaps.

    I would be grateful if you could help me with this.

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Location
    London, UK
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    function sayHello() {
      alert("Hello");
      document.getElementById('thelabel').innerHTML="Hello";
    }
    HTML Code:
    <label id="thelabel">Label:</label>
    <input type="button" onclick="sayHello()" value="Hello" />
    Hope that helps.

  3. #3
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    function sayHello() {
    alert("Hello");
    var tex=document.createTextNode('hello');
    document.getElementById('thelabel').appendChild(txt)
    }


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
  •