Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Submit button outside Html.BeginForm

On my page I have toolbar which comes from Masterpage, and some input fields. All input fields are inside of tag form and toolbar outside tag form. Is it possible submit form after pressing on button outside of form tag?

Please suggest, Alexander.

like image 635
Yaplex Avatar asked Dec 08 '22 04:12

Yaplex


2 Answers

You can do it with JavaScript:

<input type="button" onclick="$('#someForm').submit();" />

The disadvantage, of course, is that it breaks without JavaScript.

I don't believe you can do what you ask without JavaScript, though.

like image 60
Craig Stuntz Avatar answered Jan 03 '23 22:01

Craig Stuntz


Use the OnClick-event of the button to submit the form, f.e.:

<INPUT TYPE=BUTTON OnClick="document.formname.submit();" VALUE="Submit">
like image 20
Marty McVry Avatar answered Jan 03 '23 23:01

Marty McVry