Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use a submit <button> instead of <input> button

i want to submit a form with <button> instead of <input>. I know a <button> cant handle the form like a submit <input> and i have to use the onclick method.

I tried several things but it doesn't work

<button name="<?php echo $name; ?>" onclick="document.<?php echo $this->action; ?>.submit()"> ... ( Action URL of the form )
<button name="<?php echo $name; ?>" onclick="document.iso<?php echo rand(); ?>.submit()">... ( name of the form )
<button name="<?php echo $name; ?>" onclick="window.location.href='<?php echo $this->action; ?>'">... ( Action url of the form )

Does someone know an answer ?

like image 447
bobbybackblech Avatar asked Jan 04 '14 09:01

bobbybackblech


People also ask

How to submit form when Click on input type?

The <input type="submit">, when inside a form element, will submit the form when clicked. Another useful 'special' button is the <input type="reset"> that will clear the form. The question is about <input> and <button> tags. You provided useful information about <input> in your answer, but it lacks the <button> side.

What is a submit button in HTML?

Definition and Usage The <input type="submit"> defines a submit button which submits all form values to a form-handler. The form-handler is typically a server page with a script for processing the input data. The form-handler is specified in the form's action attribute.

What does a click on a submit button do?

A click on a submit button sends the form's data to the web page defined by the action attribute of the element. A click on a reset button resets all the form widgets to their default value immediately. From a UX point of view, this is considered bad practice. A click on a button button does... nothing!

What is the difference between <Button> and <input type="submit>?

<button> is newer than <input type="submit">, is more semantic, easy to stylize and support HTML inside of it. While the other answers are great and answer the question there is one thing to consider when using input type="submit" and button. With an input type="submit" you cannot use a CSS pseudo element on the input but you can for a button!


1 Answers

You can use the type="submit" like property of button

<button type="submit" name="<?php echo $name; ?>">Submit</button>
like image 161
Arun P Johny Avatar answered Oct 10 '22 02:10

Arun P Johny