Hello I have the following problem I have a dynamic select that gives the user an option and depending on that option throws other options are 2 select this is the code
<div class="container">
<div class="row">
<div class="col-md-4">
<p>Cantidad de coolers
<select id="cantidad" name="cantidad" class="form-control">
</select>
</p>
</div>
<div class="col-md-4">
<p>Coolers
<select id="coolers" name="coolers" class="form-control">
</select>
</p>
</div>
<div class="col-md-4">
<p><br><button id="enviar" type="submit" class="btn btn-default btn-block">Enviar</button></p>
</div>
</div>
<div class="row">
<div class="col-md-4">
<p><b>El resultado es: </b></p><p id="seleccion"></p>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js">
</script>
<script type="text/javascript" src="js/index.js"></script>
This selection works with an AJAX code that stores the selected values and then returns them to the html this is the ajax code
$(document).ready(function(){
$.ajax({
type: 'POST',
url: 'cargar_listas.php'
})
.done(function(listas_rep){
$('#cantidad').html(listas_rep)
})
.fail(function(){
alert('Hubo un errror al cargar las listas_rep')
})
$('#cantidad').on('change', function(){
var id = $('#cantidad').val()
$.ajax({
type: 'POST',
url: 'cargar_coolers.php',
data: {'id': id}
})
.done(function(listas_rep){
$('#coolers').html(listas_rep)
})
.fail(function(){
alert('Hubo un errror al cargar los vídeos')
})
})
$('#enviar').on('click', function(){
var resultado = 'Cantidad: ' + $('#cantidad option:selected ').text() +
' Coolers elegido: ' + $('#coolers option:selected').text()
$('#resultado1').html(resultado);
$.post("envio.php", {"resultado":resultado});
});
});
Now the Select and the ajax work perfectly since the end is printed on the screen the selected values
Now my problem is the following I want to take the Values that are printed on the screen by means of AJAX in an ID and pass them to a php variable to store or use that value in another side
in this case the variable that stores the values is called (result)
var resultado = 'Cantidad: ' + $('#cantidad option:selected ').text() +
' Coolers elegido: ' + $('#coolers option:selected').text()
and the ID where the variable is stored is called # result1
Now I use this code in ajax to send the variable to php
$.post("envio.php", {"resultado":resultado});
and in the url envio.php I call the variable in this way
<?php
echo $_GET['resultado'];
?>
Now my question is how I can do to pass the ajax variable result to php and if I'm having a good time as I call it in envio.php
Thank you I hope to see it was clear