M
M
mindgrow2018-03-15 12:55:35
HTML
mindgrow, 2018-03-15 12:55:35

How to use checkboxes with the same names but located in different forms on one html page?

Good afternoon!
On the page-view there are several buttons - info-boxes, by clicking on each of which opens the corresponding modal form. Each info box has its own modal form. The modal form contains the data of the corresponding product/service, which can be changed. Save, delete, confirm .. There is a checkbox among the data (for example, Recorded by administrator).
The main page has a List model.
To generate modal forms, I use PartialView with the SomeModel model, one of the fields of which is of type bool (recorded by the administrator)
The problem is that if all the data in different modal forms is successfully changed on save, although they all have the same name (because they are generated by the same PartialView). Then the checkbox data changes correctly only in the first modal form, in all other modal forms - they cannot even be selected.
Please tell me how to solve this problem. And is it possible to make sure that checkboxes with the same names work correctly in different modal forms on the same web page?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mindgrow, 2018-03-15
@mindgrow

For some reason, as soon as I asked, I found a solution...
You can create several checkboxes with the same name, but always different id. Then everything will work.
Each box check must have its own label

<input type="checkbox" class="filled-in" id="ig_checkbox1" name="ig_checkbox">
                                            <label for="ig_checkbox1"></label>

I use AdminBSBMaterialDesign
<div class="col-md-6">
                                    <div class="input-group input-group-lg">
                                        <span class="input-group-addon">
                                            <input type="checkbox" class="filled-in" id="ig_checkbox1" name="ig_checkbox">
                                            <label for="ig_checkbox1"></label>
                                        </span>
                                        <div class="form-line">
                                            <input type="text" class="form-control">
                                        </div>
                                    </div>
                                </div>
                <div class="col-md-6">
                                    <div class="input-group input-group-lg">
                                        <span class="input-group-addon">
                                            <input type="checkbox" class="filled-in" id="ig_checkbox2" name="ig_checkbox">
                                            <label for="ig_checkbox2"></label>
                                        </span>
                                        <div class="form-line">
                                            <input type="text" class="form-control">
                                        </div>
                                    </div>
                                </div>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question