[英]Get value from input date and show in the another input date by ajax
When <input class="boton" type="checkbox">
is changed, get value from <input type='date' id='fechai' name='fechai' class='fechai'>
and show it on <input type="date" id="fechai-cambio" name="fechai5">
with ajax. 当
<input class="boton" type="checkbox">
更改时,从<input type='date' id='fechai' name='fechai' class='fechai'>
并在<input type="date" id="fechai-cambio" name="fechai5">
with ajax。 Can include jquery. 可以包括jquery。 Ive tried multiple things but I can only get it to show on the alert.... I posted both of them below just in case because the second one is shown within a while.
我尝试过多种东西,但我只能在警报上显示它......我在下面发布了它们以防万一,因为第二次显示在一段时间内。 I need for the first date to show in all the boxes that have been checked.
我需要在所有已检查过的框中显示第一个日期。
$('.boton').change(function () {
var fechai = new Date($('#fechai').val());
$.ajax({
type: 'post',
data: {fechai:fechai},
success: function(response){
//Show the var fechai in the #fechai-cambio
alert(fechai);
}
});
});
<label for='superv' >Nombre de Equipo</label>
<select name='superv' id='superv'>
'<option></option>'";
while($row = mysqli_fetch_array($superv))
{
echo "<option value='$row[IDSUPERVISOR]'>$row[NOMEQUIPO]</option>";
}
echo" </select>
<label for='cantp' >Cantidad de Personas</label>
<input type='text' id='cantp' name='cantp' readonly>
<label for='razon' >Fecha Inicio</label>
<input type='date' id='fechai' name='fechai' class='fechai' >
<br>";
while($row = mysqli_fetch_array($result)){
echo ' <tr>
<td>'.$row['NOMBRE'].' '.$row['APELLIDO_P'].'</td>
<td class="text-center"><input class="boton" type="checkbox" name="checkbox[]" value="'.$row['IDLIBRETA_PERSONAL'].'"></td>
<td><input type="date" id="fechai-cambio" name="fechai5" ></td>
<td>'.$row['NOMBRE'].'</td>
</tr>';
}
echo "<button id='btn_form' type='button' onclick='realizaGrupo()'>Grabar</button>";
I do not why you want to use AJAX. 我不是你想要使用AJAX的原因。 Where you can simply do like this with jquery
你可以用jquery简单地做到这一点
$('.boton').change(function () {
var fechai = $('#fechai').val();
$('#fechai-cambio').val(fechai);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.