Answer the question
In order to leave comments, you need to log in
How to pass form data from 3 select and display it below on screen?
There are 3 selects.
<div class="container">
<div class="row text-center">
<H1 class="mb-3">Заказ пиццы</H1>
<form action="" method="post" name="ourf">
<div class="form-group">
<select id="single" class="form-control asd" name="search" >
<option value="" disabled selected style='display:none;'>Выберите пиццу</option>
<?php foreach($article as $object): ?>
<option value ="<?=$object['price']?>"><?=$object['name']?></option>
<?php endforeach ?>
</select>
<select class="form asd" id="single1" name="search" >
<option value="" disabled selected style='display:none;'>Выберите размер</option>
<?php foreach($article1 as $object): ?>
<option value ="<?=$object['price']?>"><?=$object['size']?></option>
<?php endforeach ?>
</select>
<select id="single2" class="form asd" name="search" >
<option value="" disabled selected style='display:none;'>Выберите пиццу</option>
<?php foreach($article2 as $object): ?>
<option value ="<?=$object['price']?>"><?=$object['name']?></option>
<?php endforeach ?>
</select>
</div>
</form>
</div>
</div>
<div id="result"></div>
<input type="submit" id="target" value="Отправить" name="search1">
Answer the question
In order to leave comments, you need to log in
If there are always 3 selects, then you can go head-on
$('form[name="ourf"]').submit(function(e) {
e.preventDefault();
var
form = $(this),
select1 = form.find('select:first-child').val(),
select2 = form.find('select:nth-child(2)').val(),
select3 = form.find('select:last-child').val();
$.post(document.location.href, {action: 'selectsPost', select1: select1, select2: select2, select3: select3},
function(data) {
//тут обработка ответа
console.log(data);
}
);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question