Re: Dynamic dropdown / select
After some time on this. Here are the options that I see.
I have tested this option in a sample using different tables (sakila) as an example.
http://downloads.mysql.com/docs/sakila-db.zip (using actor/film_actor as my text tables)
back to your fields …
-
S1 = Code
S2 = Ranges
S1 = Select; auto: SELECT code from code_table; check AJAX Processing to update S2
S2 = Select; auto: SELECT code,xvar from ck_ranges WHERE code = ‘{s1_code_fieldname}’
new_table:
CREATE TABLE IF NOT EXISTS ck_ranges (
code
int(11) NOT NULL,
xvar int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
– adding your ranges for each code
INSERT INTO ck_ranges (code, xvar) VALUES
(1, 20),
(1, 19),
(1, 18),
…
(2, 15),
(2, 14),
(2, 13),
…
(3, 12),
(3, 11),
(3, 10);
This will update S2 when S1 is changed.
-
The other option is to create an AJAX on change event on the code S1 and then write a function that grabs the min,max and then has to create a for/loop all the values and then use PHP in that event to populate S2.
http://www.tech-evangelist.com/2007/11/22/php-select-box/
That seems like a lot of extra work when you could just create a new table and be done with it.
The problem you have is that your min/max values will require you to create custom code to handle what you want. If you create the table in option 1, then you can use the built-in features of SC5 without having to create code to ‘explain’ the fields min/max to your form/controls.
Regards,
Scott.