Hi guys
i have a switch statement attached to a text fields cauculate field -
it is required to show/hide various fileds
it is behaving very weird - if you make an initial selection its fine - everything shows/hides correctly - but if you change you selection more than a few times it seems to default to only showing a couple of the second set of fields
i guess there must be an error in it somewhere, but after several hours of frustration, i still cant get it to work
can anyone spot the error?
here is the switch
switch(Any_affected_kids_droplist.rawValue) {
case "1":
page35.enrol_affchidONE_sub.presence = "hidden";
page14.affchildONE_sub.presence = "hidden";
page36.enrol_affchidtwo_sub.presence = "hidden";
page15.affchildTWO_sub.presence = "hidden";
page37.enrol_affchidTHREE_sub.presence = "hidden";
page16.affchild_THREE_sub.presence = "hidden";
page38.enrol_affchidFOUR_sub.presence = "hidden";
page17.affchild_FOUR_sub.presence = "hidden";
page39.enrol_affchidFIVE_sub.presence = "hidden";
page18.affchild_FIVE_sub.presence = "hidden";
page40.enrol_affchidSIX_sub.presence = "hidden";
page19.affchild_SIX_SUB.presence = "hidden";
break;
case "2":
page35.enrol_affchidONE_sub.presence = "visible";
page14.affchildONE_sub.presence = "visible";
page36.enrol_affchidtwo_sub.presence = "hidden";
page15.affchildTWO_sub.presence = "hidden";
page37.enrol_affchidTHREE_sub.presence = "hidden";
page16.affchild_THREE_sub.presence = "hidden";
page38.enrol_affchidFOUR_sub.presence = "hidden";
page17.affchild_FOUR_sub.presence = "hidden";
page39.enrol_affchidFIVE_sub.presence = "hidden";
page18.affchild_FIVE_sub.presence = "hidden";
page40.enrol_affchidSIX_sub.presence = "hidden";
page19.affchild_SIX_SUB.presence = "hidden";
break;
case "3":
page35.enrol_affchidONE_sub.presence = "visible";
page14.affchildONE_sub.presence = "visible";
page36.enrol_affchidtwo_sub.presence = "visible";
page15.affchildTWO_sub.presence = "visible";
page37.enrol_affchidTHREE_sub.presence = "hidden";
page16.affchild_THREE_sub.presence = "hidden";
page38.enrol_affchidFOUR_sub.presence = "hidden";
page17.affchild_FOUR_sub.presence = "hidden";
page39.enrol_affchidFIVE_sub.presence = "hidden";
page18.affchild_FIVE_sub.presence = "hidden";
page40.enrol_affchidSIX_sub.presence = "hidden";
page19.affchild_SIX_SUB.presence = "hidden";
break;
case "4":
page35.enrol_affchidONE_sub.presence = "visible";
page14.affchildONE_sub.presence = "visible";
page36.enrol_affchidtwo_sub.presence = "visible";
page15.affchildTWO_sub.presence = "visible";
page37.enrol_affchidTHREE_sub.presence = "visible";
page16.affchild_THREE_sub.presence = "visible";
page38.enrol_affchidFOUR_sub.presence = "hidden";
page17.affchild_FOUR_sub.presence = "hidden";
page39.enrol_affchidFIVE_sub.presence = "hidden";
page18.affchild_FIVE_sub.presence = "hidden";
page40.enrol_affchidSIX_sub.presence = "hidden";
page19.affchild_SIX_SUB.presence = "hidden";
break;
case "5":
page35.enrol_affchidONE_sub.presence = "visible";
page14.affchildONE_sub.presence = "visible";
page36.enrol_affchidtwo_sub.presence = "visible";
page15.affchildTWO_sub.presence = "visible";
page37.enrol_affchidTHREE_sub.presence = "visible";
page16.affchild_THREE_sub.presence = "visible";
page38.enrol_affchidFOUR_sub.presence = "visible";
page17.affchild_FOUR_sub.presence = "visible";
page39.enrol_affchidFIVE_sub.presence = "hidden";
page18.affchild_FIVE_sub.presence = "hidden";
page40.enrol_affchidSIX_sub.presence = "hidden";
page19.affchild_SIX_SUB.presence = "hidden";
break;
case "6":
page35.enrol_affchidONE_sub.presence = "visible";
page14.affchildONE_sub.presence = "visible";
page36.enrol_affchidtwo_sub.presence = "visible";
page15.affchildTWO_sub.presence = "visible";
page37.enrol_affchidTHREE_sub.presence = "visible";
page16.affchild_THREE_sub.presence = "visible";
page38.enrol_affchidFOUR_sub.presence = "visible";
page17.affchild_FOUR_sub.presence = "visible";
page39.enrol_affchidFIVE_sub.presence = "visible";
page18.affchild_FIVE_sub.presence = "visible";
page40.enrol_affchidSIX_sub.presence = "hidden";
page19.affchild_SIX_SUB.presence = "hidden";
break;
case "7":
page35.enrol_affchidONE_sub.presence = "visible";
page14.affchildONE_sub.presence = "visible";
page36.enrol_affchidtwo_sub.presence = "visible";
page15.affchildTWO_sub.presence = "visible";
page37.enrol_affchidTHREE_sub.presence = "visible";
page16.affchild_THREE_sub.presence = "visible";
page38.enrol_affchidFOUR_sub.presence = "visible";
page17.affchild_FOUR_sub.presence = "visible";
page39.enrol_affchidFIVE_sub.presence = "visible";
page18.affchild_FIVE_sub.presence = "visible";
page40.enrol_affchidSIX_sub.presence = "visible";
page19.affchild_SIX_SUB.presence = "visible";
break;
}
thanks heaps!
Solved! Go to Solution.
Views
Replies
Total Likes
You may have one of your variable misspelled. I see a pattern in your naming scheme except for this object, page36.enrol_affchidtwo_sub. The word "two" is lower case instead of upper case, "TWO" like all the other objects. This may be the cause of your weird behavior.
Thanks
Views
Replies
Total Likes
Can you attach your form (or just a sample) ?
Nith
Views
Replies
Total Likes
I didn't study your script super carefully, however, I'm thinking I understand what is going on. When you make the initial selection, you are hiding some fields. Your next selection hides more fields. Pretty soon, after a few selections you have a lot of hidden fields (which shouldn't be). These fields will remain hidden until their presence property is returned to visible. You'll need to do that each time your switch statement fires.
So, place a script right before before your switch statement, returning all affected fields to visible. Then your switch statement should work as expected. Also, I noticed you don't have a "default" in your switch. Probably a good idea to have a default as a fall back.
Good luck,
Stephen
You may have one of your variable misspelled. I see a pattern in your naming scheme except for this object, page36.enrol_affchidtwo_sub. The word "two" is lower case instead of upper case, "TWO" like all the other objects. This may be the cause of your weird behavior.
Thanks
Views
Replies
Total Likes