Reputation: 43
<body>
<input type="date" name="quantity" maxlength="10" id="create_date">
<input type="button" value="Siguiente" id="submit_date">
</p>
</body>
$(document).ready(function() {
var aux = "";
var paux = "";
$("#submit_date").click(function(event){
aux = $("#create_date").val();
paux = $("#create_date").val();
// Get date creation and store in DB
$.post("store_date.php",
{
fecha:aux
},
function(data,status){
//alert("Data: " + data + "\nStatus: " + status);
});
$('#content').empty();
$("#content").load("escritura.php");
// Here I have the date in "paux" and
// I want to put it in ["escritura.php"->input:id:fecha_acta->value] but..
// This doesnt work and I dont know why..
$("#fecha_acta").val(paux);
});
});
<form action="tratamiento.php" method="POST">
<input name="fecha_acta" id="fecha_acta" type="hidden" value="0" />
<input id="mi_submit" type="submit" class="submit button" value="Save">
</form>
Upvotes: 0
Views: 52
Reputation: 10994
Because the request is asynchronous your script runs before the elements are loaded in the page.
Use the callback and make the changes there (once the request is complete and the elements are in the DOM)
$("#content").load("escritura.php", function(){
$("#fecha_acta").val(paux);
});
Upvotes: 1