Page 1 of 1

dropdown and javascript

Posted: Mon Oct 21, 2013 11:57 am
by paparazia
hi, i have two dropdown fields, in the first i have countries and the data of the second depend on the choices of the first.
but in the first, i have some contries without city in the second and i want that the second dropdown appears only if the contry have some city?
how can i di it?

Re: dropdown and javascript

Posted: Tue Oct 22, 2013 5:21 am
by paparazia
Actually I would like to bring up the second dropdown when the user selects the first list a country that has cities in the second list.
Otherwise, the second list should not be visible ..
is not it I have to use javascript? but how?

Re: dropdown and javascript

Posted: Tue Oct 22, 2013 4:22 pm
by David

Re: dropdown and javascript

Posted: Wed Oct 23, 2013 12:01 pm
by paparazia
thank you David, I came to link the two drop-down lists, cities of the second list is loaded from the selected in the first list of countries .... but now I want that when the user selects a country without city the second dropdown, it does not appear or is inactive.

Re: dropdown and javascript

Posted: Fri Oct 25, 2013 7:35 am
by paparazia
It is possible to use the 'onfocus'???

Re: dropdown and javascript

Posted: Fri Oct 25, 2013 9:08 am
by Scott Klement
I don't see why you'd use onfocus, here?

If you are loading the dropdowns from an RPG program, whether it's empty or not should be known at the time the screen is drawn, so I would use an onload event to disable/enable the dropdown based on whether there is any data in it.

If you are loading them from JavaScript, then I would just add the enable/disable to the end of that JavaScript code.

If they are database-driven, that might make it trickier.

Re: dropdown and javascript

Posted: Mon Oct 28, 2013 5:37 am
by paparazia
sorry Scott, i see that it's not possible to use the onfocus

Data drop-down lists are loaded from two tables. And the data is displayed correctly. But if the country selected have'nt data in the second list, I want the second list to be disabled.