...

Creating Button elements - form-submit issue

Choopernickel
04-30-2004, 05:04 PM
Greetings, salutations.

When creating an input element, one must declare the type, which then becomes immutable.el = document.createElement('input');
el.type = 'text';Fine. No problem. However! When creating a button element, one may not declare the type, as it is created as immutable..el = document.createElement('button');
el.type = "button";
My issue is that I don't want this button to submit the form, which it does because the default button type is "submit." Quote the spec:<!ELEMENT BUTTON - -
(%flow;)* -(A|%formctrl;|FORM|FIELDSET)
-- push button -->
<!ATTLIST BUTTON
...
type (button|submit|reset) submit -- for use as form button --
...>
The oddest part is that after the button is created, alert(el.type) yields undefined in the alert.

Does anyone know more about using the button element with DOM?

sad69
04-30-2004, 05:50 PM
That is kind of weird..

To be quite honest with you, I've used this in the past, but apparently it's incorrect:

el = document.createElement("<button onClick='alert()'>");
el.appendChild(document.createTextNode("push me"));


And that should create a regular button, not a <input type="submit">

I've never had the opportunity to test this out in NS or any other browser other than IE, so that may be IE only..

Hope that helps,
Sadiq.

swmr
05-01-2004, 12:23 PM
try: el.setAttribute("type", "button")



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum