www.webdeveloper.com
Results 1 to 3 of 3

Thread: Create button programmatically not declaratively

  1. #1
    Join Date
    Nov 2011
    Posts
    1

    Create button programmatically not declaratively

    How do I make the text "Commit" appear on the button?

    This is what i have done:

    var Canvas = {
    buttonCommit: TBE.CreateButtonElement (this.displayWidth,this.displayHeight/10*2)
    };
    Canvas.buttonCommit.style.position = 'relative';
    Canvas.buttonCommit.type="button";
    Canvas.buttonCommit.value="Commit";

    ... which is equivalent to this (copied from Developer Console):

    <button style="width: 100px; height: 40px; position: relative;" type="button" value="Commit"></button>

  2. #2
    Join Date
    Oct 2005
    Posts
    843
    The value attribute is used for input tags buttons, while you are using a button tag, the attribute you want to use is innerHTML so:
    Code:
    Canvas.buttonCommit.innerHTML="Commit";
    Welsh

  3. #3
    Join Date
    Oct 2011
    Posts
    40
    Quote Originally Posted by welsh View Post
    The value attribute is used for input tags buttons, while you are using a button tag, the attribute you want to use is innerHTML so:
    Code:
    Canvas.buttonCommit.innerHTML="Commit";
    Right it will work

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles