Pankaj Waghmare Pankaj Waghmare - 5 months ago 11
PHP Question

How to auto fill date after selecting current date and number of years

I have 2 text fields and 1 drop down box, if I have selected date in first text box after that I have to select number of year from drop down.

So how can I auto fill the next date in second text box of that selected no of year from drop down.

this is text box code

<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-tent"></i></span>
<input type="text" name="purchese_date" id="tbDate" class="pwaf form-control" value="<?php echo isset($_POST['purchese_date']) ? $_POST['purchese_date'] : '' ?>" placeholder="Enter Purchese Date eg:dd/mm/yyyy"/>
<div class="form-group">
<select class="form-control pwafs" name="year">
<option value="#">- Select Year-</option>
<option value="1"> 1</option>
<option value="2"> 2</option>
<option value="3"> 3</option>
<option value="4"> 4</option>
<option value="5"> 5</option>
<option value="6"> 6</option>
<option value="7"> 7</option>
<option value="8"> 8</option>
<option value="9"> 9</option>
<option value="10"> 10</option>
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-blackboard"></i></span>
<input type="text" name="renual_date" id="tbDate" class="form-control pwafr" value="<?php echo isset($_POST['renual_date']) ? $_POST['renual_date'] : '' ?>" placeholder="Enter Renual Date eg:dd/mm/yyyy"/>
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-th-list"></i></span>
<input type="text" name="customer_id" id="tbDate" class="form-control" value="<?php echo isset($_POST['customer_id']) ? $_POST['customer_id'] : '' ?>" placeholder="Enter Customer Id"/>

this is php code

$domains = new domains;
if (isset($_POST['add-domain'])) {

$errors = $domains->validate_domains_members();
if (count($errors)) {
$emsg = $errors;
$eclass = "alert-danger";
} else {

if ($domains->save($domains->table, $_POST)) {
$emsg = "User Added Successfully";
$eclass = "alert-success";
<?php if (isset($emsg)) { ?>
<div class="alert <?php echo $eclass; ?>"><?php echo $emsg; ?></div>
<?php } ?>


try this

        var date = $(".pwaf").val();
        var year = date.replace("/", "");
        var year2 = year.replace("/", "");
        var year3 = year2.substring(4, year2);
        var add = +year3 + +$(this).val();
        var final = date.slice(0,-4);