[SOLVED] Â Calculate on the fly - but with strings |
7/26/2019 2:39:53 PM |
PHPRunner General questions | |
M
Melanie authorDevClub member
I am trying to calculate a string for a field on an ADD screen. I am using the example for calculating tax on the fly - but using my own fields and it isn't working. I am using autofill in that field also - so then I want that string and then want to add additional strings. This is what I have in Javascript on load event: |
|
![]() |
lefty 7/26/2019 |
I am trying to calculate a string for a field on an ADD screen. I am using the example for calculating tax on the fly - but using my own fields and it isn't working. I am using autofill in that field also - so then I want that string and then want to add additional strings. This is what I have in Javascript on load event: var ctrlcheckin = Runner.getControl(pageid, 'check_in_date'); var ctrlcheckout = Runner.getControl(pageid, 'check_out_date'); var ctrlsubject = Runner.getControl(pageid, 'Subject_line_for_email'); function func() { ctrlsubject.setValue(ctrlsubject.getValue + (ctrlcheckin.getValue) + (ctrlcheckout.getValue)); }; ctrlcheckin.on('keyup', func); ctrlcheckout.on('keyup', func); / So autofill puts the employee name in subject_line_for_email and then I really want to add after that - 7/24/2019 - 7/31/2019 so that the field should be: Joe Blow - 7/24/2019 - 7/26/2019. I am thinking I am not doing the function correctly to get the string. |
M
|
Melanie authorDevClub member 7/26/2019 |
Check This. Here And Here
|
![]() |
lefty 7/26/2019 |
Thanks - changed to this, but my field still isn't getting populated when I change the date fields: I am now getting the text 'undefined' written to that field when I put a date in check in. var ctrlcheckin = Runner.getControl(pageid, 'check_in_date'); var str_date1 = ctrlcheckin.getStringValue(); var ctrlcheckout = Runner.getControl(pageid, 'check_out_date'); var str_date2 = ctrlcheckout.getStringValue(); var ctrlsubject = Runner.getControl(pageid, 'Subject_line_for_email'); function func() { ctrlsubject.setValue( ); }; ctrlcheckin.on('keyup', func); ctrlcheckout.on('keyup', func);
|
M
|
Melanie authorDevClub member 7/26/2019 |
Getting very close now: |
M
|
Melanie authorDevClub member 7/26/2019 |
Getting very close now: var ctrlcheckin = Runner.getControl(pageid, 'check_in_date'); var ctrlcheckout = Runner.getControl(pageid, 'check_out_date'); var ctrlsubject = Runner.getControl(pageid, 'Subject_line_for_email'); function func() { ctrlsubject.setValue( ctrlsubject.getStringValue() + ' - ' + ctrlcheckin.getStringValue() + ' - ' + ctrlcheckout.getStringValue() ); }; ctrlcheckin.on('keyup', func); ctrlcheckout.on('keyup', func); But I get this??? last name, first name - 7 - - 7/ - - 7/1 - - 7/1/ - - 7/1/1 - - 7/1/19 - - 7/1/19 - - 7/1/19 - 7 - 7/1/19 - 7/ - 7/1/19 - 7/2 - 7/1/19 - 7/20 - 7/1/19 - 7/20/ - 7/1/19 - 7/20/1 - 7/1/19 - 7/20/19
|
![]() |
lefty 7/26/2019 |
Getting very close now: var ctrlcheckin = Runner.getControl(pageid, 'check_in_date'); var ctrlcheckout = Runner.getControl(pageid, 'check_out_date'); var ctrlsubject = Runner.getControl(pageid, 'Subject_line_for_email'); function func() { ctrlsubject.setValue( ctrlsubject.getStringValue() + ' - ' + ctrlcheckin.getStringValue() + ' - ' + ctrlcheckout.getStringValue() ); }; ctrlcheckin.on('keyup', func); ctrlcheckout.on('keyup', func); But I get this??? last name, first name - 7 - - 7/ - - 7/1 - - 7/1/ - - 7/1/1 - - 7/1/19 - - 7/1/19 - - 7/1/19 - 7 - 7/1/19 - 7/ - 7/1/19 - 7/2 - 7/1/19 - 7/20 - 7/1/19 - 7/20/ - 7/1/19 - 7/20/1 - 7/1/19 - 7/20/19
|
M
|
Mark Kramer 7/26/2019 |
Okay great . I learned something as well.
|
![]() |
lefty 7/27/2019 |
I know you did not ask for this but I ran into date subtraction / addition issues when I tried to do something like what you are doing with dates and times.. So thought it might help.. (Used it the "Javascript onload event" of the page) var DO = new Date(CD.getValue()); //date opened var DOP = Date.parse(DO) // Grab value and covert it to 'ms' so it is an usable number instead of a string var dp = Date.parse(d) // Grab value and covert it to 'ms' so it is an usable number instead of a string // get total seconds between the times var delta = Math.abs(dp - DOP) / 1000; // calculate (and subtract) whole days var days = Math.floor(delta / 86400); delta -= days 86400; // calculate (and subtract) whole hours var hours = Math.floor(delta / 3600) % 24; delta -= hours 3600; // calculate (and subtract) whole minutes var minutes = Math.floor(delta / 60) % 60; delta -= minutes * 60; // what's left is seconds var seconds = delta % 60; =(days)+" day(s) "+(hours)+" hr(s) "+(minutes)+" min "+(seconds)+" sec " [color="#FF0000"]TO.setValue(tto); Red of course are your own varables..
|