Jump to content

add 14 days to value


Recommended Posts

hi everyone, I have to text fields, the second needs to take its initial value from the user inputted date in the first and add 14 days but generate it on the fly, Has anybody experience with this?

    </tr>
    <tr>
      <td class="KT_th"><label for="intraartapproval">Art Appr. Date</label></td>
      <td><input type="text" name="intraartapproval" id="intraartapproval" value="<?php echo KT_escapeAttribute($row_rsworksorders['intraartapproval']); ?>" size="32" />
        <?php echo $tNGs->displayFieldHint("intraartapproval");?> <?php echo $tNGs->displayFieldError("worksorders", "intraartapproval"); ?></td>
    </tr>
    <tr>
      <td class="KT_th"><label for="intraestimatedinstall">Est. Install</label></td>
      <td><input type="text" name="intraestimatedinstall" id="intraestimatedinstall" value="USER INPUTTED DATE + 14 DAYS" size="32" />
        <?php echo $tNGs->displayFieldHint("intraestimatedinstall");?> <?php echo $tNGs->displayFieldError("worksorders", "intraestimatedinstall"); ?></td>
    </tr>

Link to comment
https://forums.phpfreaks.com/topic/201605-add-14-days-to-value/
Share on other sites

I havn't tried anything like that myself, but I think you will need to use client side scripting on the onChange attribute of the first text box to get the result you are looking for in the second to apear without sending the form back to the server for pre-proccessing.

@liamloveslearning

 

Are you familiar with JavaScript?

 

 

If so, you should be able to do something like this:

<form name="myForm">
<label for="intraartapproval">Art Appr. Date</label> <input type="text" name="intraartapproval" id="intraartapproval" size="32" onchange="myForm.intraestimatedinstall.value = Number(this.value) + 14;" /><br />
<label for="intraestimatedinstall">Est. Install</label> <input type="text" name="intraestimatedinstall" id="intraestimatedinstall" size="32" />
</form>

 

 

Note that the above code only works with integers. You'll need to modify the code to work with dates. It looks like it may be a little bit of work, but you should be able to use some of the JavaScript functions found here:

http://www.elated.com/articles/working-with-dates/

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.