This topic is locked

Custom Dropdown OnSelected

10/22/2008 7:43:16 PM
PHPRunner General questions
K
kamil6x author

Looking to implement the functionality of enabling and populating a dropdown with values from a database table, based on the selection of the dropdown above.
Eg.

1)dropdown1 selected by user.

2)Javascript executed to:

a)select from database where XXX = "selection from dropdown1".

b)create dropdown 2 with values from (a).

c)unhide dropdown 2.
Been searching the forum and can't find this in an easy few lines of code. Can anyone help?

T
thesofa 10/23/2008

can you not use the dependant dropdown feature in the page where you set up the dropdown?

K
kamil6x author 10/31/2008

I wanted to do that, but the field doesn't appear in the 'Category Control' drop down.
So I have the following layout:

1)Table 1 is the main table, it has a foreign Key for table 2.

2)Table 2 has a foreign key for table 3.
so I have the form for table 1. To insert the 'table 2 Key' dowpdown, I need a dropdown with table 3 to filter selection for table 2. Eg. a simple "Province", "City" for Example.
So table 1 is User Address. (Main form)

Table 3 is Province. (dropdown 1)

Table 2 is City. (dropdown 2)
So City is Related to Province and Address; but address is not related to Province only to City. The only way I have been able to do this is with custom code, but PHPrunner reformats and changes the custom HTML each time it saves and reloads the project (another thing I need resolved).
So I don't understand why when I try to put (Dropdown 2) to be dependent on (Dropdown 1), "dropdown 1" doesn't appear in the "Category Control" list.

can you not use the dependant dropdown feature in the page where you set up the dropdown?

M
mustafa 11/2/2008

I did it many times without any problem.

You should check database structure for 'foreign keys'.
Here is an example:


It works!
Best Regards,

Mustafa

K
kamil6x author 11/2/2008

Your database design is incorrect. Your address table doesn't need a ProviceID this relation is captured in the City Table. With your design you can have City A linked to Province B, and Address C, linked to City A and Province D. (Eg. An address is now linked to two different provinces.).
Try doing it without ProvinceID in the Address Table. Doesn't work for me.
Kamil

I did it many times without any problem.

You should check database structure for 'foreign keys'.
Here is an example:

It works!
Best Regards,

Mustafa