【问题标题】:Get value from input date and show in the another input date by ajax从输入日期获取值并通过 ajax 在另一个输入日期中显示
【发布时间】:2019-08-19 16:47:08
【问题描述】:

<input class="boton" type="checkbox"> 改变时,从<input type='date' id='fechai' name='fechai' class='fechai'> 获取值并使用ajax 在<input type="date" id="fechai-cambio" name="fechai5"> 上显示它。可以包含 jquery。 我已经尝试了多种方法,但我只能让它显示在警报中......我将它们都发布在下面以防万一,因为第二个会在一段时间内显示。我需要在所有已选中的框中显示第一个日期。

    $('.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>";

【问题讨论】:

    标签: jquery date input


    【解决方案1】:

    我不明白你为什么要使用 AJAX。在哪里你可以简单地用 jquery 做这样的事情

    $('.boton').change(function () {
        var fechai = $('#fechai').val();
        $('#fechai-cambio').val(fechai);
    });
    

    【讨论】:

    • 太好了,谢谢它有效。但是有了id,我只能得到第一个复选框的日期而不是所有的复选框(每个复选框的复选框和日期#fechai-cambio)
    猜你喜欢
    • 1970-01-01
    • 2020-09-18
    • 2020-05-02
    • 1970-01-01
    • 2023-03-31
    • 1970-01-01
    • 2019-05-22
    • 2013-08-06
    • 2020-04-10
    相关资源
    最近更新 更多