Hello,
I"m fairly new to PHPmaker. Recently installed and purchased the 2020 version.
I think what i’m trying to do is extremely simple so i’m sure this is user error, after searching here, and reading through the script examples here is what i’m looking at.
I have a form for select employees to replace a paper time sheet with an electronic one. (construction industry.) it’s still manually filling out time, not punching in/out etc. (It’s mainly supervisors inputting data)
form has spot for job, job type, cost code selection, as well as hours. (required fields.)
I have a checkbox for timeoff. it defaults to no(hidden) with a yes checkbox.
What i’m trying to do is: when the box is checked for yes, the required fields of hours, and job information are updated with either, null or other required data so that they don’t have to select anything to show that no work was done.
Code is:
$(“input[name=‘x_off_work’]”).click(function() {
if (this.checked) { // If checked
If the “off_work” field is a lookup field (with lookup table or user values), you need to use the “updatedone” events, see the topic Server Events and Client Scripts → Client Scripts → “Table-Specific → Add/Copy page” → Client Script → Example 3 in the help file.
If you use $(this).fields(“x_Job_Num”), you need to remove “x_”.
If the “off_work” field is a lookup field (with lookup table or user
values), you need to use the “updatedone” events, see the topic Server
Events and Client Scripts → Client Scripts → “Table-Specific →
Add/Copy page” → Client Script → Example 3 in the help file.
If you use $(this).fields(“x_Job_Num”), you need to remove
“x_”.
Thanks for the response, the ‘off_work’ field is not a lookup field. It is a check box yes/no marker for data storage purposes.
i suspect i’m close here.
code posted has comments where the remaining issue is coming from.
additional information: this is in the gridadd form. supervisors are generally putting in time for multiple employees, so i’m trying to update the form values, and not looking to update the DB at this point in the coding process.
the intent is to speed up the process a little for the required fields that technically are not required for time off, but still get legitimate data in the field(s) for that line item.
here is the code that is working with one exception.
thanks for the points in the right direction…
I"m watching the console as I make these selections and not seeing any errors, so i’m not sure where the issue might be. I suspect i’m missing a context statement to update the value of the dynamic selection but I’ve tried adding and additional .change option without success.
//time off on change test
$(“input[data-field=‘x_off_work’]”).change(function() { // Field1 has multiple inputs in Grid-Add/Edit so they should be selected by data-field attribute
if (this.value == “Y”) {
$(this).fields(“Job_Num”).value(“9999999”); //works as intended
$(this).fields(“Job_let”).value(“-”); //works as intended, this is a parent field to dynamic selection
$(this).fields(“Job_let”).change(); //works as intended. correctly triggers and populates single option in next select box
$(this).fields(“Job_Code”).value(“99999”); //the value exists in the drop list, as the only option, does not update.
$(this).fields(“Reg_Hrs”).value(“0”); //works as intended
$(this).fields(“Comment”).value(“OFF WORK”); //works as intended
$(this).fields(“Vehicle”).value(“No”); //works as intended
} else {
//do nothing
}
Yes, Job_Code and Job_let are both populated by lookup table.
when i call
these 3 lines, are where i’m sure i have it wrong.
$(this).fields(“Job_let”).value(“-”); //works as intended, this is a parent field to dynamic selection
$(this).fields(“Job_let”).change(); //works as intended. correctly triggers and populates single option in next select box
$(this).fields(“Job_Code”).value(“99999”);
after the first line, the value changes in the Job_let field. and after the .change() is called, the child field Job_Code populates correctly with the choice “99999”
But using the .value() on that field doesn’t make it happen.
I feel i’m needing to use the function script, (document).on(“updatedone”, function(e, args)
but i don’t think i’m using it correctly.