Welcome Guest, Not a member yet? Register   Sign In
How to use <button type=button>
#11

[eluser]theprodigy[/eluser]
Quote:html5 way: You will need to play with it.
InsiteFX:
He said he was good with input type='submit'. He's trying to do it with button, not 'submit' button. He needs javascript, not css.

Wondering Coder:
You should be able to use something similar to
Code:
&lt;script type="text/javascript"&gt;
function submit_form(form_id)
{
    document.forms[form_id].submit();
}
&lt;/script&gt;
&lt;form id='my_form' method='post'&gt;
// your other form stuff, like inputs, radios, etc
<button>Submit</button>
&lt;/form&gt;
I'm not sure why you want to submit a form without using a submit button, but that is basically how you would do it.

Edit: it keeps taking away the onclick attribute, but you want to have onclick="submit_form('my_form')" inside the opening button tag.
#12

[eluser]InsiteFX[/eluser]
Got cha!

My mistake.

InsiteFX
#13

[eluser]jayrulez[/eluser]
I think
Code:
<button type="submit">Click me</button>
will submit your form automatically without you having to rely on using javascript. It is rendered no differently from type="button"... Only difference is that it will submit your form. I think you may want to try that instead of using type="button". However, you did not specify why you want to use type="button" so I can't really say.

Edit note:
http://www.w3schools.com/tags/att_button_type.asp

apparently it doesn't work for IE... Well I'm not sure about the later versions like 8/9
#14

[eluser]theprodigy[/eluser]
jayrulez,

I'm not seeing on that page where it mentions that it doesn't work in IE? It says to always specify the type to override any defaults (IE="button", all others="submit"), but I don't see where it says it doesn't work in IE. Can you point me to it?
#15

[eluser]jayrulez[/eluser]
[quote author="theprodigy" date="1306106810"]jayrulez,

I'm not seeing on that page where it mentions that it doesn't work in IE? It says to always specify the type to override any defaults (IE="button", all others="submit"), but I don't see where it says it doesn't work in IE. Can you point me to it?[/quote]

My mistake. I was just quickly browsing over it with my eyes and noticed "Internet Explorer" and assumed so Smile
#16

[eluser]theprodigy[/eluser]
heh, I understand completely. I had to read it twice to make sure I didn't miss it. I'm so used to reading "IE doesn't support [insert ANYTHING here]", that I thought I overlooked it.
#17

[eluser]Wondering Coder[/eluser]
hehe, got it working. used type submit and add a hidden field in it.
Code:
<button type="submit"> & &lt;input type="hidden"&gt;.

Anyway I had to used image buttons that specifically used <button></button> type in my css file.

thanks for the help!. ^_^
#18

[eluser]theprodigy[/eluser]
if you wanted image buttons, why didn't you use
Code:
&lt;input type="image" /&gt;
It does the same thing as submit buttons, but uses an image instead.




Theme © iAndrew 2016 - Forum software by © MyBB