Answer the question
In order to leave comments, you need to log in
How to pass array from form to PHP using AJAX method?
Friends, there are no direct thoughts, I don’t know how to do it, for the first time I encounter such a task.
There is a form with custom SELECTs on the site, which are created automatically, their number is unknown.
Each SELECT writes the result of the selection, the name and value of the parameter into its hidden fields:
<div class="option">
<span class="name">РАЗМЕР</span>
<select class="option-select">
......
</select>
<input type="hidden" class="name-option" name="name-option[]" value="РАЗМЕР">
<input type="hidden" class="value-option" name="value-option[]" value="XL">
</div>
<div class="option">
<span class="name">ШТ</span>
<select class="option-select">
......
</select>
<input type="hidden" class="name-option" name="name-option[]" value="ШТ">
<input type="hidden" class="value-option" name="value-option[]" value="5">
</div>
<div class="option">
<span class="name">ПОЛ</span>
<select class="option-select">
......
</select>
<input type="hidden" class="name-option" name="name-option[]" value="ПОЛ">
<input type="hidden" class="value-option" name="value-option[]" value="М">
</div>
.....
$.ajax({
type: "POST",
url: "send.php",
data: {
options: name-option,
valueoptions: value-option
},
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question