Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple forms with shared fields

Tags:

html

webforms

How to make multiple forms with shared fields without using javascript?

<input type=text name=username />
<form action="/users">
    ... some fields ...
</form>
<form action="/admins">
    ... some another fields ...
</form>
like image 674
Andrey Kuznetsov Avatar asked Feb 26 '26 16:02

Andrey Kuznetsov


1 Answers

It is no necessary to have the input tag inside the form: an input can be associated with its form using its form attribute.

It would be nice if forms could share inputs, but i haven't heard of this. Maybe we should ask W3C to introduce this in HTML6?

UPDATE: One workaround would be to have a single form with multiple "Submit" buttons, using <input type="submit" name="..." value="..." /> or <button type="submit" name="..." value="...">...</button> elements, so that all the fields get submitted when any button is pressed, and the server side can then check which button was pressed.

like image 152
Alexey Avatar answered Mar 01 '26 12:03

Alexey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!