I have been using the scripts from the Purchase Order sample that work with the Country and States/Provinces drop down lists and have modified them to fit my needs. The scripts work great. However I have a drop down list that is in a repeating sub form and the only the drop down list in the first occurance of the sub form works. The others don't.
I put this line of code in a field called drpOrderedByTeam.
I have read the thread you link to and just took another look at it.
Actually it's not data from a data file but uses arrays that I have set up in the script object. I took the Country and States/Provinces script from the Purchase Order form sample and changed the data in the arrays so when I pick a work team from one drop down the another drop down list is populated with the names of the chosen work team.
I also have another script that uses the work team and populates another drop down list with certain jobs that pertain to that work team. This drop down is repeated in occurances of it's containing sub form and they are all the same.
By the way this is a time sheet I'm working up so a user can pick his or her team then on each row (sub form) there is a drop down list that will list some jobs that are routine. So if the user is working on "Job #1" and "Job #3" and "Job #8" they can choose each one of those jobs from a drop down in three rows and keep track of the time.
Well, I don't know what your getJobsOther() method does so I can't comment on that. But basically what you want to do is have script on the initialize event of your drop down that will use addItem() to populate it based on the values in your arrays. That way, when a new instance of the subform is instantiated the initialize event for the new drop down fires and it gets populated.
Well let me try another approach and say what I am wanting to do.
I'm working on a dynamic time sheet form that has the potential to grow from 1 page to at least 2 pages. There are two fields at the top of the form that are team and team member fields respectively. A user will choose the team he/she belongs to from a list in the teams drop down list field. Then the user chooses his/her name from the names drop down list field which changes depending on which team is chosen.
There is a sub form called DetailTitlesSF that contains an AddRowBtn button and titles of columns. There are 10 columns named ItemNumberTitle, JobTitleTitle, TasksTitle, TasksTitle, TasksTitle, TasksTitle, TasksTitle, CountTitle, CountTitle, CountTitle. The 5 TaskTitle fields are drop down fields and thier lists change depending Which team is selected from the team drop down list fields. The 3 CountTitle drop down lists are hard coded because they always stay the same.
Right under the DetailTitlesSF sub form there is a sub form called DetailsSF which contains DeleteRowBtn and a table in which one of the cells contains a drop down list field called ItemNumber in which the list again changes depending on which team is selected from the team drop down.
The ItemNumber drop down needs to have the same list items in each occurance of the DetailsSF sub form. When the form starts out with a minimum of 6 occurances of the DetailsSF subform when it is opened in Acrobat.
I want to use the DetailTitlesSF sub form as an Overflow Leader so when added occurances of any DetailsSF sub forms go to another page the drop down list fields will work.
I really don't know how to accomplish this. I have been using the sample of the scripts found in the dynamic purchase order form where if a user selects Canada from a drop down list then the user can choose a Province from a States/Provinces drop down or United State and get a list of States in the States/Provinces drop down. I got it to work with the teams and team member names fields but the others don't work so well.
Based on your explanations, I've attempted to re-create your form and I think I've got it working the way you'd like it to.
There are some difficulties with using fields in table headers which are replicated on subsequent pages because while new instances of the header subform and the fields it contains are created, you don't have access to these instances using the header's Instance Manager (I think this is a bug but I'm not sure). This means that you can't iterate through the instances of the header in order to populate the task lists depending on the selection in the team list. One solution for this is to make all header fields Global (select each field and, in the Object palette's Binding tab, set the Default Binding property to Global). This means that all instances of these fields will share the same value. The effect is that when you change the value of a field on an instance of a header on any page, the change will be replicated on all instances on all pages. The catch, though, is when you use lists in the header. Making list fields global doesn't mean that their item lists are global -- which causes other headaches.
In the end, because of the problems I've described, I had to resort to cheating a little but if you think about it, it's not really cheating. What the form does is whenever the team list value changes, it removes all instances of the DetailsSF rows. This has the effect of also removing all instances of the DetailTitlesSF headers accross the current page set (and removes all pages but the first one). Then 6 new instances of the DetailsSF row are generated and the DetailTitlesSF header is re-populated using the new selection in the team list. After that, if a new page gets generated because of the number of instances of the DetailsSF rows, the new instances of the task lists in the new instances of the DetailTitlesSF header will have the correct list of items based on the current value of the team list. In the end, even though I'm cheating by removing all instances of the DetailsSF row in order to reset the lists in the DetailTitlesSF header, it's not really cheating because if you change teams, then it should be assumed that all data entered doesn't apply anymore because the tasks change as well... Convinced?
The best way to understand this is to check-out the sample form.
Ok. I worked with this thing again after a pause to do some other work and after modifying some of the scripts in the sample I finally have a basic working form. For the most part. All of the drop downs work after a new Team is chosen from the Team drop down list. Now I just need to figure out how to get the item number drop down to work when a new row is added. Right now everything is tied to the change event in the team drop down.
I thought maybe I could put something in the click event of the new row button that would utilize the script object that populates the item number drop down fields but nothing so far is working. In the mean time I'm going to play around with a few more ideas.
> Ok. I worked with this thing again after a pause to do some other work and after modifying some of the scripts in the sample I finally have a basic working form. For the most part. All of the drop downs work after a new Team is chosen from the Team drop down list. Now I just need to figure out how to get the item number drop down to work when a new row is added. Right now everything is tied to the change event in the team drop down.
> I thought maybe I could put something in the click event of the new row button that would utilize the script object that populates the item number drop down fields but nothing so far is working. In the mean time I'm going to play around with a few more ideas.
Try using the initialize event on your item number drop down. When the new row is added, this
initialize event will get called, allowing you to populate the items in the drop down list.