从var使用Pikaday和onchange添加月份

时间:2016-04-22 16:34:12

标签: javascript php pikaday

我有两个德国格式日期。如何在日期2中添加可变数量的月份,我使用Pikaday。 Wenn我改变了datepicker1然后它应该是datepicker2 = datepicker2 + addedMonth

          <label for="bis">bis</label>
      <input type="text" name="bis" id="datepicker1" value="<?php echo date("d.m.Y", strtotime($bis)); ?>" onchange="updateDate(this.value, <?php echo $addedMonth; ?>)">



<?php
$geprueft_bis ="22.04.2016";
$pruefen_wann ="22.10.2016";
$addedMonth=6;
?>
<script>
function updateDate(val, intervall) {
    p = document.getElementById("datepicker1").value;

    newp = val+intervall;


    document.getElementById("datepicker2").value = newp;
}

</script>
              <label for="bis">bis</label>
      <input type="text" name="bis" id="datepicker1" value="<?php echo date("d.m.Y", strtotime($bis)); ?>" onchange="updateDate(this.value, <?php echo $addedMonth; ?>)">


      <label for="wann">pruefen wann</label>
      <input type="text" name="wann" id="datepicker2" value="<?php echo date("d.m.Y", strtotime($wann)); ?>">
    <script src="moment.js"></script>
    <script src="pikaday.js"></script>
    <script>
        var picker = new Pikaday({
            field: document.getElementById('datepicker1'),
            format: 'DD.MM.YYYY',
            onSelect: function() {
                console.log(this.getMoment().format('Do MMMM YYYY'));
            }
        });
        var picker = new Pikaday({
            field: document.getElementById('datepicker2'),
            format: 'DD.MM.YYYY',
            onSelect: function() {
                console.log(this.getMoment().format('Do MMMM YYYY'));
            }
        });
    </script>

0 个答案:

没有答案