1

I have my lending page and need some help with form so i have 2 products in one form

> <form action="x.html" method="post" id="lead-form" validate>
    <select class="form-control" name="requested_product" id="sa">
                                        <option id="x" value="x.html" selected="selected">product x</option>
                                        <option id="y" value="y.html">product y</option>
                                    </select>
<input class="form-control" id="sz" name="email" type="email" placeholder="E-mail" tabindex="2" required="email">
<input class="form-control" id="sf" name="first_name" type="text" placeholder="First Name" required>
<input class="form-control" id="sl" name="last_name" type="text" placeholder="Last Name" required>
<button requird="email" class="btn btn-primary btn-lg btn-form">Get Started</button>
</form>

so how i do redirect for page of product X when i choose it and submit it or do redirect to page of product Y when i choose it and submit

Anthony Fink
  • 27
  • 1
  • 5

1 Answers1

0

You have some options to solve this.

You need to decide if you want to solve the routing in frontend or backend.

If you do it in frontend you can always use javascript to change the form action attribute when the selection changes.

You could also have a richer application to handle the request submit with ajax instead of the pure native form, if you are new to this you could use jQuery as starter kit.

Take a look to this post about submit form with jQuery: Submit a form using jQuery

If you want to solve this in the backend, the form will always submit to the same url, then in the backend app you read the selected item and decide to which one redirect the response.

Example in PHP: How to make a redirect in PHP?

I hope this helps you

Javier Cobos
  • 1,172
  • 10
  • 22
  • You should start to read about js and forms. I.E: https://developer.mozilla.org/en-US/docs/Learn/HTML/Forms/Form_validation – Javier Cobos Oct 14 '17 at 15:54