V
V
Viktor Gubanov2015-11-29 22:42:33
PHP
Viktor Gubanov, 2015-11-29 22:42:33

How to transfer the checkbox'a selection to another form and then send the data of the two forms in a letter?

The usual sending of customer data from the site to the mail.
Sending itself works, but not as we would like.
I can send the usual form on submit, but I don’t understand how to do this in the case described below.
The gist of the question is this:

  • There is a website: fitmoms.ru
  • A person chooses a course or one of three lessons, a form appears to fill in the data and by clicking the "ORDER" button the form flies to the mail and the user is redirected to the page depending on the type of purchase (either a full course or a lesson)

You can select lessons using checkbox'a
Checkbox is designed as a form and if I click on the submit button, the letter immediately flies to the mail, and I do not have time to fill in the fields with name, mail and phone number.
If I click on a regular button, then I cannot track what exactly the user has selected in the checkbox.
Question:
How to transfer data from checlbox'a to another form?
Or how to pass them to the php handler, but not send an email, but wait for the second form to submit?
5f07037f5e7b4c19ba85b50f0e531245.png
Form code with checkboxes:
<form method="post" action="mailer.php" id="buy-lesson_form">
                            <div class="buy_radio">

                                <div class="radio">

                                    <label>
                                        <input type="radio" name="buy_radio" id="buy_hometrain" value="hometrain" checked>
                                        <span></span>Домашние тренировки
                                    </label>

                                </div>
                                <div class="radio">
                                    <label>
                                        <input type="radio" name="buy_radio" id="buy_eat" value="eat">
                                        <span></span>Питание
                                    </label>
                                </div>
                                <div class="radio">
                                    <label>
                                        <input type="radio" name="buy_radio" id="buy_motivation" value="motivation">
                                        <span></span>Мотивация
                                    </label>
                                </div>
                            </div>
                             <input type="submit" class="buy_button" data-toggle="modal" data-target="#buy_lesson" type="submit" value="submit">

                            <button type="button" class="buy_button" data-toggle="modal" data-target="#buy_lesson">button</button>
                        </form>

6f267887c132462eba99a4bf8f6c8b15.png
Form code with fields name, phone:
<form method="post" action="mailer.php" id="superForm-lesson">
                            <div class="pop-title">УРОК</div>
                            <input type="text" value="" placeholder="ИМЯ*" title="Введите имя" name="name" class="tooltip textValidation name inputfield">
                            <input type="text" value="" placeholder="EMAIL*" title="Введите e-mail" name="email" class="tooltip emailPhoneValidation email inputfield">
                            <input type="text" value="" placeholder="VK или НОМЕР ТЕЛЕФОНА*" title="Введите аккаунт VK или Skype" name="skype" class="tooltip textValidation skype inputfield">
                            <input type="text" value="УРОК" placeholder="" title="" name="lessontype" class="hidden">
                            <button type="submit" class="order__btn-lesson buy_button rigth">Заказать</button>

                        </form>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Goncharov, 2015-11-30
@agmegadeth

The first form should not have an actiona, because now the first form submit sends to the mail sending script. It should be stopped like this:

form.on("submit", function(event) {
  event.preventDefault();
}

And then you can check further in the script which checkbox is selected and pass its value to a previously prepared hidden field in the second form. In the second form, the submit will also send the value of the hidden field where the selected lesson will be stored.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question