P
P
Pavel Rozhkov2018-03-01 15:55:10
MODX
Pavel Rozhkov, 2018-03-01 15:55:10

How to display checkbox value in Formit?

Hi friends. The problem is the following.
The list of services is displayed in the form with checkboxes
The form itself


<section class="application">
    <div class="container">
        <h2>Оставьте заявку</h2>
        
        <form  method="POST" action="">
            <div class="row">
                <div class="col-md-4">
                    <div class="form-group letterName">
                        <label for="fName">Как к вам обращаться<span class="form-required">*</span></label>
                        <span class="error"></span>
                        <input type="text" class="form-control" name="name">
                    </div>
                    <div class="form-group inputnumber">
                        <label for="fNumber">Контактный телефон<span class="form-required">*</span></label>
                        <span class="error"></span>
                        <input type="text" class="form-control form-phone" name="phoneNumber" pattern="^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{7,10}$" placeholder="+7 (999) 999-99-99">
                    </div>
                    <div class="form-group inputemail">
                        <label for="fEmail">E-mail<span class="form-required">*</span></label>
                        <span class="error"></span>
                        <input type="email" class="form-control" name="email" placeholder="[email protected]">
                        <INPUT TYPE="HIDDEN" name="pageurl" VALUE="http://askmeplz.com/" />
                    </div>
                </div>
                <div class="col-md-4">    
                    <div class="form-group question">
                        <label for="fWishes">Напишите что вас интересует</label>
                        <span class="error"></span>
        <textarea aria-required="true" rows="8" cols="45" name="message" id="message" placeholder="Сообщение" value=""></textarea>
                    </div>
                </div>
                 <div class="col-md-4">  
                    <div class="fCheck">
                        <p>Выберите услугу</p>
                        
                    </div>
                </div>
            </div>
            <button type="submit" name="call20" class="btn btn-staro btn-staro-an">Отправить</button>
            <span class="error"></span>
        <label><input type="hidden" name="soglasie[]" value="">
        <input type="checkbox"  name="soglasie[]" value="согласие"  
         onclick="showHide('soglasie-input');" >
        Согласен с политикой<a href=""> конфиденциальности</a></label>
        </form>
    </div>
</section>

The content of inputTpl
<label><input type="hidden" name="[]" value=""><input type="checkbox" value="" name="[]"  onclick="showHide('-input');" ><span></span></label>

It turns out that checkboxes are added with the addition of a new service. But how can I pass in the message chunk the value of the checkbox that the user selected when sending the message.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Golyagin, 2018-03-03
@pro100pav

Everything is quite simple, is added to the name at the end, for example

1
<input name="kreslo0[]" type="checkbox" value="kreslo0">
see more here Building Complex Forms on MODX Revo with FormIt

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question