Showing and hiding multiple tables with a drop down list

Avatar

Avatar
Validate 1
Level 1
j_mcg
Level 1

Likes

2 likes

Total Posts

4 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
j_mcg
Level 1

Likes

2 likes

Total Posts

4 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
j_mcg
Level 1

29-11-2011

I am trying to make a drop down list so that users can select the number of tables that are shown/generated when they specify how many tables they need to fill out (there is 1 table to fill out for each day of a multi=day event, max of 5).

I thought I would use a similar javascript as the one I used in another place onthe form which was applied to radio buttons for showing or hiding a specific table. When I applied this to the drop down and added more lines the scipt was not working, with some playing around I got it to work, but now it seems thre is an issue with which value is being selected in the list. When a user selects a certain value, it shows the previous value (so when I selected 4 days, which has a velue of "3", the message box I added for testing purposed is telling me I selected value "2"). 

I am just wondering if there is an easier way to do the function i am trying to do, or if drop down is the best solution? The max number of tables that can be filled out is 5, so the drop down seems like an ideal way of resticting that for the person filling out the form.

This is an exmaple of the script I have applied to the drop down, as a "change" action. It's repeated 4 times for each value.

form1.Page2.DropDownList1::change - (JavaScript, client)

if (this.value == "2") {

form1.Page2.TableDay1.presence = "visible";

form1.Page2.TableDay2.presence = "visible";

form1.Page2.TableDay3.presence = "hidden";

form1.Page3.TableDay4.presence = "hidden";

form1.Page3.TableDay5.presence = "hidden"; 

}

else {

form1.Page2.TableDay1.presence = "hidden";

form1.Page2.TableDay2.presence = "hidden";

form1.Page2.TableDay3.presence = "hidden";

form1.Page3.TableDay4.presence = "hidden";

form1.Page3.TableDay5.presence = "hidden";

}

if (this.value == "3") {

form1.Page2.TableDay1.presence = "visible";

form1.Page2.TableDay2.presence = "visible";

form1.Page2.TableDay3.presence = "visible";

form1.Page3.TableDay4.presence = "hidden";

form1.Page3.TableDay5.presence = "hidden"; 

}

else {

form1.Page2.TableDay1.presence = "hidden";

form1.Page2.TableDay2.presence = "hidden";

form1.Page2.TableDay3.presence = "hidden";

form1.Page3.TableDay4.presence = "hidden";

form1.Page3.TableDay5.presence = "hidden";

}

I've looked it over and tried a few different things, and my coworker who is much better than me with sciprting is also at a loss at the moment - he isn't familiar with LiveCycle, less than I so any help is appreciated. Many thanks again as my last issue (the script for the radio buttons) was solved on here. Thanks again.

View Entire Topic

Avatar

Avatar
Give Back 3
Level 2
past-tense
Level 2

Likes

9 likes

Total Posts

85 posts

Correct reply

10 solutions
Top badges earned
Give Back 3
Give Back
Validate 1
Boost 5
Boost 3
View profile

Avatar
Give Back 3
Level 2
past-tense
Level 2

Likes

9 likes

Total Posts

85 posts

Correct reply

10 solutions
Top badges earned
Give Back 3
Give Back
Validate 1
Boost 5
Boost 3
View profile
past-tense
Level 2

29-11-2011

The issue that you're seeing with the value being off is due to the fact that you're using the change event. The change event fires *before* the new value is assigned to the field. This event is usually used to intercpet changes. If you want to keep using the change event, you can get the new value with:

xfa.event.newText;

This, however, will get the display text instead of the value behind. You could probably check the dropdown nodes to see what the value is, but I think you should just avoid all this by adding your code to each hideable subform's layout:ready event.. for example, for the first one, in the layout_ready event of TableDay2 (as day1 should never be hidden, as I understand) put:

this.presence  = (DropDownList1.rawValue >= 1) ? "visible" : "hidden";

TableDay3 would have:

this.presence  = (DropDownList1.rawValue >= 2) ? "visible" : "hidden";

etc.

Let me know if this helps.

- Scott