• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 504
  • Last Modified:

createElement("button") makes a tiny little button

Hi!

I am very new to javascript and there may well be a better way to do this than the way I am trying to do it, but the problem I have seems like it is something the should be trivial, despite my complete inability to fix it.

I am creating a number of form elements using javascript, including a submit button, using the following code.  

The problem is, the button appears and works, but it is super tiny and has no writing in it (at least none that I can see).

I have tried specifying height and width (first in the javascript and then in the div) - both seem to have failed to solve the problem.

If anyone can tell me how to make my submit button normally sized I would really appreciate it!
Thanks!


//this gets the div tag that I am appending the button to.
var sButton = document.getElementById("sbt");

//this creates my button
var submitting = document.createElement('button');
   submitting.setAttribute("name", "Submit");
   submitting.setAttribute("type", "submit");
   submitting.setAttribute("value","Submitted");

//this appends the button to the div
sButton.appendChild(submitting);

//this is the html code for the div
<div id = "sbt"></div>

Open in new window

0
JolineZ
Asked:
JolineZ
  • 2
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
Standard 'submit buttons' are <input> elements.  http://www.w3schools.com/tags/tag_input.asp  'buttons' are <input> elements.
0
 
JolineZAuthor Commented:
Thanks! I knew it had to be something silly and this fixed it immediately.
0
 
Dave BaldwinFixer of ProblemsCommented:
thanks, glad to help.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now