2
所以即时尝试是将POST输入添加到Onclick function
上的窗体。所以,当我通过Javascript
检查信息是否可以时,在通过Javascript form.submit()
进行操作之前,我想添加更多信息,例如IdCrono。 什么IM,现在做的是在Form.action = "myPhpFunction.php"
通过动作添加GET变量所以这将是如何通过javascript为表单添加值?
"myPhpFunction.php?key=1&IdCrono=1"
反正加密钥和IdCrono通过JavaScript中的POST?
我的代码如下所示:
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>
为'key,id'添加一个空值的两个隐藏输入,并给它们一个id(html属性)。然后在提交之前,您可以在提交表单之前更新隐藏的输入。 'document.getElementById(“IdCrono”)。value = id;' – JustOnUnderMillions
你的表单有'POST',你正在创建'GET'就是故意的吗? – RST
@RST是它的故意,因为我不知道我是否可以动态添加POST变量来发送,我不喜欢使用GET变量。这就是为什么我问是否有办法做到这一点。 –