liamloveslearning Posted May 13, 2010 Share Posted May 13, 2010 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> Quote Link to comment https://forums.phpfreaks.com/topic/201605-add-14-days-to-value/ Share on other sites More sharing options...
Muddy_Funster Posted May 13, 2010 Share Posted May 13, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/201605-add-14-days-to-value/#findComment-1057638 Share on other sites More sharing options...
cyberRobot Posted May 13, 2010 Share Posted May 13, 2010 @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/ Quote Link to comment https://forums.phpfreaks.com/topic/201605-add-14-days-to-value/#findComment-1057692 Share on other sites More sharing options...
liamloveslearning Posted May 13, 2010 Author Share Posted May 13, 2010 Thanks cyberrobot, unfortunately im a complete novice with JS however Quote Link to comment https://forums.phpfreaks.com/topic/201605-add-14-days-to-value/#findComment-1057742 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.