Я хочу получить значение добавленных элементов после отправки. Он добавляет правильные атрибуты имени, но я не могу получить значение
<script>
<?php
$options = '';
while($searched_species_adding = mysqli_fetch_array($search_species_adding)){
$name = $searched_species_adding['name'];
$options = $options.'<option>'.$name.'</option>';
}
echo 'var options = "'.$options.'";';
?>
var count=2;
$( "#add-species" ).click(function() {
var html=$("<tr id='species-"+count+"'><td><select name='species-"+count+"' class='form-control'>"+options+"</select></td><td><input id='species-num-"+count+"' name='species-num-"+count+"' class='form-control' type='number'></td></tr>");
$("#species-container").append(html);
$("#species-num-"+count).prop('required',true);
count++;
var wew = ($('tr', $("#wew").find('tbody')).length);
$(".tr-num").remove();
$("#species-container").append("<input class='tr-num' type='hidden' value='"+wew+"' name='tr_count'>");
$(".tr-num").val(wew);
});
$( "#remove-species" ).click(function() {
count--;
$("#species-"+count).remove();
var wew = ($('tr', $("#wew").find('tbody')).length);
$(".tr-num").val(wew);
});
</script>
Выше приведен скрипт для добавления. И вот мой код получения значений в форме после отправки:
if(isset($_POST['add-delivered'])){
$requestor = $_POST['requestor'];
$org_office = $_POST['org_office'];
$address = $_POST['address'];
$date_pickup = $_POST['date_pickup'];
$location = $_POST['location'];
$planting_type = $_POST['planting_type'];
$tr_count = $_POST['tr_count'];
$species = '';
for($x = 1; $x <= $tr_count; $x++){
$species = $species.$_POST['species-'.$x];
}
echo '<script>alert("'.$tr_count.'")</script>';
exit();
}