So what im trying is to add POST inputs to a form on an Onclick function
. so, when i check the info is OK via Javascript
, before doing via Javascript form.submit()
I want to add more information, for example an IdCrono.
What im doing right now is in Form.action = "myPhpFunction.php"
is add GET variables via the action so it would be
"myPhpFunction.php?key=1&IdCrono=1"
anyway to add Key and IdCrono to the POST via javaScript?
My code looks like this:
function GuardarMilestone(a) {
var id = a.id;
var idCrono = Math.floor(a.id / 10);
alert(idCrono);
var form = document.getElementById("Form" + id);
if (id % 10 == 0) {
//alert("Resto 0");
var date = form.elements["FechaInicio"];
} else {
//alert("Resto 5");
var date = form.elements["FechaFin"];
}
if (date.value != "") {
form.action = "InteriorInternalFunciones.php?key=1&id=" + id;
form.target = "_self";
form.submit();
} else {
alert("Please fill in the date before saving");
}
}
<form method="POST" id="Form<?php echo $rstMilestones->fields['IdCronograma']; ?>0" action="">
<input type="date" style="font-size: 9px; font-style: bold;" name="FechaInicio" value="<?php echo $strFaseInicioSinFormato;?>">
<input type="hidden" name="IdCronograma" value="<?php echo $rstMilestones->fields['IdCronograma']; ?>">
<a href="#botones" id="<?php echo $rstMilestones->fields['IdCronograma']; ?>0" onclick="GuardarMilestone(this)"><img src="images/PC_si.png" alt="Save"></a>
<a href="#botones" id="<?php echo $rstMilestones->fields['IdCronograma']; ?>0" onclick="EditarFechaCronograma(this)"><img src="images/PC_no.png" alt="cancel"></a>
</form>