• Resolved coolwen22

    (@coolwen22)


    Hi,

    The datepicker is showing when I press on the input field, but it is passing wrong values.
    I want to display some text after user choose date from the datepicker.

    Here’s my code:

    <?php /* Template Name: calendar */ ?>
    <?php wp_enqueue_script("jquery"); ?>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.js"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.css" rel="stylesheet" />
    <link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/redmond/jquery-ui.css" rel="stylesheet" />
    
    <link href="https://cdnjs.cloudflare.com/ajax/libs/datepicker/0.6.5/datepicker.min.js" />
    
    <?php
    
    get_header();
    ?>
    
      <section id="primary" class="content-area">
        <main id="main" class="site-main">
    
    <script>
    $.noConflict();
    jQuery(document).ready(function($) 	{
    
      $('#app_fill').datepicker({
        dateFormat: "dd/mm/yy"
      });
    
      $('#app_reg').datepicker({
        dateFormat: "dd/mm/yy"
      });
    });
    </script>
    
    </head>
    <body>
    <form action="calendar.php" method="post" autocomplete="off">
    <div class="form-group">
      <label>When was the application filed?</label>
      <div class='input-group date' id='datetimepicker1'>
        <input type='text' class="form-control" name="app_fill" name="app_fill" id="app_fill" required />
        <span class="input-group-addon">
          <span class="glyphicon glyphicon-calendar"></span>
        </span>
      </div>
    </div>
    
    <div class="form-group">
      <label>Is the mark registered?</label>
      <select id="mark" name="mark" class="form-control" required>
      <option value="yes">Yes</option>
      <option value="no">No</option>
    </select>
    </div>
    
    <div class="form-group">
      <label>If yes, when was it registered?</label>
      <div class='input-group date' id='datetimepicker2'>
        <input type='text' class="form-control" name="app_reg" id="app_reg" required/>
        <span class="input-group-addon">
          <span class="glyphicon glyphicon-calendar"></span>
        </span>
      </div>
    </form>
    
    <input type="submit" name="submit" value="submit">
    </div>
    <div class="text">
    	
    </div>
    
    <?php
    //if mark is not registered
        if(isset($_POST['app_fill']) && ($_POST['mark'] == 'no')) {
    
    //-------------------------application date-----------------------------//
           //add 3 years
          $date_app_fill = $_POST['app_fill'];
          $date_app_fill=date("d/m/Y", strtotime($date_app_fill));
          $input1 = new DateTime($date_app_fill);
          $input1->add(new DateInterval('P3Y'));
          $three_y=$input1->format('j F Y');
            
          //add 3 years 6 months
          $date_app_fill_1 = $_POST['app_fill'];
          $input2 = new DateTime(date("d/m/Y", strtotime($date_app_fill_1)));
          $input2->add(new DateInterval('P3Y6M'));
          $three_y_six_m=$input2->format('j F Y');
      
          //output text
          echo "
     		The declaration of actual use or non-use of the mark should be filed not later than ".$three_y." but a six-month extension until ".$three_y_six_m."   may be requested. The extension requested should be filed not later than ".$three_y.".
     			";
    	}
    
      //if mark is registered
    	if(isset($_POST['app_fill']) && ($_POST['mark'] != 'no')){
    
    //-------------------------application date-----------------------------//
          //add 3 years
          $date_app_fill = $_POST['app_fill'];
          $date_app_fill=date("d/m/Y", strtotime($date_app_fill));
          $input1 = new DateTime($date_app_fill);
          $input1->add(new DateInterval('P3Y'));
          $three_y=$input1->format('j F Y');
            
          //add 3 years 6 months
          $date_app_fill_1 = $_POST['app_fill'];
          $input2 = new DateTime(date("d/m/Y", strtotime($date_app_fill_1)));
          $input2->add(new DateInterval('P3Y6M'));
          $three_y_six_m=$input2->format('j F Y');
    
    //-------------------------register date-----------------------------//
          //add 5 years 0 months 1 day
          $date_app_reg = $_POST['app_reg'];
          $input3 = new DateTime(date("d/m/Y", strtotime($date_app_reg)));
          $input3->add(new DateInterval('P5Y1D'));
          $five_y_one_d=$input3->format('j F Y');
    
          //add 6 years 
          $date_app_reg_1 = $_POST['app_reg'];
          $input4 = new DateTime(date("d/m/Y", strtotime($date_app_reg_1)));
          $input4->add(new DateInterval('P6Y'));
          $six_y=$input4->format('j F Y');
    
          //add 10 years
          $date_app_reg_2 = $_POST['app_reg'];
          $input5 = new DateTime(date("d/m/Y", strtotime($date_app_reg_2)));
          $input5->add(new DateInterval('P10Y'));
          $ten_y=$input5->format('j F Y');
    
          //add 10 years minus 6 months
          $date_app_reg_3 = $_POST['app_reg'];
          $input6 = new DateTime(date("d/m/Y", strtotime($date_app_reg_3)));
          $input6->add(new DateInterval('P9Y6M'));
          $nine_y_six_m=$input6->format('j F Y');
    
          //add 10 years 6 months
          $date_app_reg_4 = $_POST['app_reg'];
          $input7 = new DateTime(date("d/m/Y", strtotime($date_app_reg_4)));
          $input7->add(new DateInterval('P10Y6M'));
          $ten_y_six_m=$input7->format('j F Y');
    
          //add 11 years
          $date_app_reg_5 = $_POST['app_reg'];
          $input8 = new DateTime(date("d/m/Y", strtotime($date_app_reg_5)));
          $input8->add(new DateInterval('P11Y'));
          $eleven_y=$input8->format('j F Y');
    
          //output text
          echo "
     		The declaration of actual use or non-use of the mark should be filed not later than ".$three_y." but a six-month extension until ".$three_y_six_m." may be requested. The extension requested should be filed not later than ".$three_y.".
    <br>
    A declaration should again be filed within one year from the 5th anniversary of the registration of the mark, or from ".$five_y_one_d." until ".$six_y.".
    <br>
    The registration is due for renewal by ".$ten_y.". The renewal application may be filed from ".$nine_y_six_m." until ".$ten_y.". After ".$ten_y.", the renewal application may still be filed not later than ".$ten_y_six_m.".
    <br>
    A declaration should then be filed within one year from the renewal of the registration of the mark, or until ".$eleven_y.", without possibility of extension.
     			";
    	}
    ?>
    
    <?php
    get_footer();

    Here’s what I’ve put in the datepicker settings:
    #app_fill,#app_reg

    Any help greatly appreciated!

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Datepicker is passing wrong values’ is closed to new replies.