Copy link to clipboard
Copied
Hi,
With your help I managed to create a timetable. Once I fill in this timetable it completes the page "classbook22" that links to it. I would now like to create a reset button for the timetable, so I can use it again for the following week. I would like to change the code, so that when I put in the week number (so week 23 instead of 22) it fills in the page "classbook23" rather than "classbook22" and NOT overwrite the data. Is this possible?
Here is the code I have used to fill in the fields for page "classbook22".
The first picture shows the timetable. You select the topic in the dropdown box and you can write into the field next to it what you want. When a certain subject is selected in the dropdown box it copies it into a field (which are hidden) on the second page (see second picture). This is the code for it:
var A = this.getField("DD1Mo22").value; var B = this.getField("1SM22").value; var C = this.getField("DKL122").value; var DKL122 = ""; if (A == "D") { DKL122 = B; } else if(A == "M") { DKL122 = ""; } else if(A == "SU") { DKL122 = ""; } else if(A == "Ku") { DKL122 = ""; } else if(A == "Mu") { DKL122 = ""; } else if(A == "S") { DKL122 = ""; } else if(A == "RK") { DKL122 = ""; } else if(A == "RE") { DKL122 = ""; } else if(A == "Med") { DKL122 = ""; } else if(A == "DaZ") { DKL122 = ""; } else if(A == "AG") { DKL122 = ""; } else if(A == "FU") { DKL122 = ""; } else if(A == "E") { DKL122 = ""; }; event.value = DKL122;
Then depending on which field is filled I accumulate all the information in a second box "Deutsch22". This is the code for this part:
// Get the field values, as strings var s1 = getField("DKL122").valueAsString; var s2 = getField("DKL222").valueAsString; var s3 = getField("DKL322").valueAsString; var s4 = getField("DKL422").valueAsString; var s5 = getField("DKL522").valueAsString; var s6 = getField("DKL622").valueAsString; var s7 = getField("DKL722").valueAsString; // Combine values, separated by a space event.target.value = s1 + " " + s2 + " " + s3 + " " + s4 + " " + s5 +" " + s6 + " " + s7;
This box is on the page "classbook22" and I don't want to delete the data that I put into this box, even if the timetable form with the dropdown fields is reset. Is that possible?
My second question is...Is it possible to use the same timetable again and copy it into the field "Deutsch23" on page "classbook23" if the weeknumber "x9" = 23 ?
I have uploaded the file so that it is maybe easier to understand. (It is pretty basic as my java script is very limited
Copy link to clipboard
Copied
This does not look like a question related to Adobe's RoboHelp product. Which product are you using?
Copy link to clipboard
Copied
No it isnt RoboHelp. Its an Acrobat DC question. Did I somehow ended up in the wrong category? Sorry. I will try and post this in the correct category.
Copy link to clipboard
Copied
I have moved it for you.
Copy link to clipboard
Copied
If you don't want a field's value to reset when you use this command then don't include that field in the list of fields to reset, or change its default value to its current value first.
For example, if you don't want to clear the value of field "Text1" then you can do this:
this.getField("Text1").defaultValue = this.getField("Text1").valueAsString;
this.resetForm();
Copy link to clipboard
Copied
"var A = this.getField("DD1Mo22").value; var B = this.getField("1SM22").value; var C = this.getField("DKL122").value; var DKL122 = ""; if (A == "D") { DKL122 = B; } else if(A == "M") { DKL122 = ""; } else if(A == "SU") { DKL122 = ""; } else if(A == "Ku") { DKL122 = ""; } else if(A == "Mu") { DKL122 = ""; } else if(A == "S") { DKL122 = ""; } else if(A == "RK") { DKL122 = ""; } else if(A == "RE") { DKL122 = ""; } else if(A == "Med") { DKL122 = ""; } else if(A == "DaZ") { DKL122 = ""; } else if(A == "AG") { DKL122 = ""; } else if(A == "FU") { DKL122 = ""; } else if(A == "E") { DKL122 = ""; }; event.value = DKL122;"
You can simplify it that way:
var A = this.getField("DD1Mo22").value;
var B = this.getField("1SM22").value;
var DKL122 = "";
if (A == "D") { DKL122 = B; }
else { DKL122 = ""; }
event.value = DKL122;
Copy link to clipboard
Copied
Thank you ever so much. This works brilliantly.
Copy link to clipboard
Copied
Now my question actually is....
is it possible to include a "reset" button. When I click that button on the timetable page. It will delete all the date in the fields "1SM22", "2SM22"...and so on WITHOUT deleting the data in field "Deutsch22"? (In my attached file this field is on a seperate page).
Copy link to clipboard
Copied
Yes, just reset the fields you want reset. The reset action takes fields names at input.
Copy link to clipboard
Copied
Thank you. The button works and resets the selected fields. However, if I would accidentally click on the field where the information from the form was copied from it would update the field and I would loose the data that was in there. Any advise?
Copy link to clipboard
Copied
You need to use a script for that. Something like this:
if (app.alert("Are you sure you want to reset the form?",2,2)==4) this.resetForm(["1SM22", "2SM22"]);
Copy link to clipboard
Copied
That works fine but I still have the issue with deleting the value. I have created a much simplified version of what I would like to achieve and have attached that file here. Maybe this is easier to understand and maybe work with.
So you put the number of the week in (I have set it up for week 22 and 23 only) and then you select a dropdown subject and enter a text in the box next to the drop down box.
So far everything works fine.
Then I would like the text that is next to the dropdown box to appear on the second page for either week 22 or week 23 depending on the number I have entered in the top left box.
The second issue is that when I press the reset button, the data on the second page disappear because the date on the first page (meaning the timetable page not the "Einstellung" page) disappear.
Copy link to clipboard
Copied
I'm sorry, I don't follow.
Copy link to clipboard
Copied
Check the Javascript console for errors.
Copy link to clipboard
Copied
There are no errors. I need to edit the code but unfortunately I don't know how.
Copy link to clipboard
Copied
When I use the dropdown I get following error:
TypeError: this.getField(...) is null
1:Field:Calculate
Copy link to clipboard
Copied
The "DateField" is missing.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Add those field names to the list of fields to reset, then.
And there's still an error in your code. If you enable the option to show the JS Console on warnings and messages (under Preferences - JavaScript), you'll see it.
Copy link to clipboard
Copied
Ah yes. Thank you!