Expand my Community achievements bar.

SOLVED

Setting defaults in dependent drop downs

Avatar

Level 3

Hi

I have two drop downs.  The second is populated (via an array) based on the choice of the first drop down.  What I would like to happen is that when the first drop down is chosen, the second drop down displays a default value that the user can change if they want one of the other choices.

It is a job request form that I am creating, it requires two drop downs to describe the job and then these choices populate the cost. When they do not use the second drop down the cost does not show up and it looks like its free!!  Not what I want.

Any help would be greatly appreciated

1 Accepted Solution

Avatar

Correct answer by
Level 10

You can set the selectedIndex property to display the default value after you load the second dropdown.

DropDownList2.selectedIndex = "0";

Index starts from 0 for the listitems. So you can set the selectedIndex to the default value's index.

Thanks

Srini

View solution in original post

5 Replies

Avatar

Correct answer by
Level 10

You can set the selectedIndex property to display the default value after you load the second dropdown.

DropDownList2.selectedIndex = "0";

Index starts from 0 for the listitems. So you can set the selectedIndex to the default value's index.

Thanks

Srini

Avatar

Level 3

Thanks Srini, that has done exactly what I want.  But it has now created an offshoot problem.

The second dropdown populates a price field (based on what is selected).  If the second drop down is not manually chosen (that is the default that been populated the dropdown and the user does not need to alter it), the price field does not behave properly.  I assume it probably just needs to be refreshed or something or an enter event or something behind the scenes.  I am new to this and so am not entirely sure what it is that I require.

I am guessing this is an easy fix and would appreciate some help

Thanks

Avatar

Level 10

What was the actual problem? Are you not getting the selected value if you do not alter the default one?

If you still have issues, you can send the for to LiveCycle9@gmail.com so I can have a look at it. Please mention where the issue is in the form.

Thanks

Srini

Avatar

Level 3

Hi Srini

I tried to email the form to you but our system is too locked down and it wont let me do it.

I will try and desrcibe the problem better.  There are two drop downs on the form.  The first determines size of paper (A4, A3 etc) and the second other details of a job (Laminating, Laminating and Backing, emailed only).  The "Details" drop down are determined by the "Size: Drop down .  These then populate a price field based on size and details.  If the "Details" drop down is left empty, the price field does not populate. 

What I am finding now with the default in "Details" drop down, is that the price field does not update automatically.  I assume this is becuase you don't actually change the "Details" drop down.  If you manually change the "Details" drop down the price works. It is as if the form needs to redraw or the fields refresh for the price to populate.

I hope this makes some mroe sense.  I know it must be hard to understand without seeing the form.

Any help will be greatly appreciated (as with the help you have already given)

Avatar

Level 10

Based on the scenario you explained, I am assuming that you have written code in the change/ click event of the dropdown. When ever you change something in the dropdowns, that event will be fired and display the Price field value.

If that is true, then place the same code code in the initialize event of the Dropdown/ Price field to populate the Price field value.

It may look like this..

     Language Java Script

    If(DropDownList1.rawValue != null && DropDownList2.rawValue != null){

           Price.rawValue = "XXXX";

    }

If you still have issues, you can copy the entire XML source from the file and save it as a text file. and send it to my email.

Thanks

Srini