I want to install two buttons in the form and process them separately.

Asked 1 months ago, Updated 1 months ago, 2 views

Is it possible to install two buttons in the form and have them take different actions?
Below is Ravel's Blade.

For example, action method.a and action method.b on Finish when you teach Next.

<form method="post" action={{route('method.a')}}>
            <input type="hidden" name="id" value="{{$id}}">                     
            <textarea type="textarea" class="textarea" id="item" name="itemList"></textarea>
                <br of >
                :<input type="text" id="sss" name="sss" value=""> 
                :<input type="text" id="ppp" name="ppp" value=""> 
                <button type="submit" class="button">Next</button>
                <br of >
            <button type="submit" class="button">Finish</button>

html laravel

2022-09-30 12:06

2 Answers

Wouldn't it be better to add the formatting attribute to the button tag?

I think the following pages will be helpful.

Preview using the format and format target attributes that can be attached to button tags introduced in html5

2022-09-30 12:06

You can use formaction to switch actions as already mentioned, and if the actions are the same, the server can receive (this will switch actions) which buttons are pressed like <button name="foo" value="bar">bar;<>>.

By the way, please be aware of when submitting by pressing the enter key instead of clicking the button in both methods are used.Many browsers say that the first button that appears in the form is submitted, but that is probably not the behavior you intend, so if applicable, you need to take action to suppress the submit by the enter key.

2022-09-30 12:06

If you have any answers or tips

© 2022 OneMinuteCode. All rights reserved.