By the way, if you use the "code" tags
it makes it a little easier to read and gives line numbers, etc. But that's okay, I copied all the text into an editor (Notepad++) to work with it.
I'm going to tackle the martial status field - if this helps you resolve the issue, hopefully you can extrapolate the changes to the other field(s) that are giving you trouble. There are only two bits of code that show or hide the marital status field.
1st on line 45 the field is hidden. This line works with either the in-process version of the form or the read-only version of the form, and this line also runs regardless of anything else going on with the form (it's one of the opening lines of code and there is no evaluating criteria to prevent this code from executing) - so it never fails to hide the field.
2nd on line 129 the field is shown. However two bits of code could prevent this from occurring:
- The code between lines 92 and 141 is only run when an event is triggered, on line 91, the code is:
$(field.fafsaStatus).on("change", function() {
- The code between lines 128 and 133 is only run when a value equates as true, on line 127, the code is:
if (fafsa == "Independent Student") {
Neither of these two items are going to occur on the read-only version of the form.
The change event is not going to occur, because there is no user interaction to cause the event to occur. The easiest way around this would be to trigger a change event when the form first loads, forcing it to always run at least once (this could probably go somewhere around line 47):
$(field.fafsaStatus).trigger("change");
The if statement is not going to evaluate as true because in the read-only version of the form, the fafsa value that is supposed to be populated on line 92 will be populated with a null value:
var fafsa = $(field.fafsaStatus).val();
The problem we have is the .val() part of command. In the in-process version of the form, this works great, but in the read-only version, it won't work, there isn't a value to retrieve, in this case, we need to retrieve the text.
Let's try this. After line 92, after we've populated the fafsa variale, let's add a new variable, I'm calling it altfafsa:
var altfafsa = $(field.fafsaStatus).text();
Then, when you evaluate the contents of the fafsa field (on line 127 and several other places), we'll evaluate both values instead of just the one:
if (fafsa == "Independent Student" || altfafsa == "Independent Student") {
Now it should evaluate as true, because either the fafsa variable or the altfafsa variable should return the expected value.
I haven't actually built out the form to test the code changes myself, but I've dealt with this kind of problem myself several times, so I'm pretty sure this will do it.