This topic is locked
[SOLVED]

 Filter a dropdown based on user selection from a radio button

11/18/2018 9:27:34 PM
PHPRunner General questions
woodey2002 author

Hi Guys,
I'm trying to filter a dropdown based on user selection from a radio button.
Just trying to figure the best way to approach it...
Any ideas would be highly appreciated
Scenario:
I have a team_table that records data for individual team members.
A team member can be either level 1 or level 2, this value is selected by the user from a radio button called team_level.
I have a team_courses_table setup as a detail table off the team_table where I plan to record data on courses individual team members have attended.
This detail table contains a dropdown called "Courses" which is a lookup of all the courses available in the courses_table (over 200 courses to choose from). The corresponding level i.e. Level 1 or Level 2 is also a field in the courses_table.
Any ideas what would be the best way filter the courses dropdown in the team_courses_table detail table to only show level 1 or level 2 courses based on the user selection from the team_level radio button, for example if the user chooses level 1 from the team_level radio button the courses dropdown will only show level 1 courses to choose from.
Best wishes,

J

admin 11/19/2018

Use 'Dependent dropdown boxes' feature. It works with radio-buttons too.

woodey2002 author 11/19/2018

Thanks Sergey,
Will the Dependent dropdown boxes' feature work if the team_level radio-button where the user chooses level 1 or level 2 is a field in the master table, while the courses lookup is a field in a view of the detail table?
I can't seem to be able to get the desired results no matter what combination of dependencies, I can't seem to reference the master table field team_level in the detail table lookup , should I try adding a new field called staff_course_level to the detail table which is auto-filled by the team_level radio-button when the user selects the desired level?
Or should I explore this option? http://asprunner.com/forums/topic/22701-custom-dependent-dropdown-boxes/
Best wishes,

J

admin 11/20/2018

After item selection in master record dropdown is made save this value in a session variable and later reference it in WHERE clause of details table dropdown. No need to use "Dependent dropdown boxes" feature in this case.

woodey2002 author 11/20/2018

Thank you.
Problem solved with the example you kindly described in the link below.
http://asprunner.com/forums/topic/22622-base-details-dropdown-from-master-table-selection/
To preserve detail table inline add functionality would a javascript onload event help me filter the dropdown in the detail as soon as the user clicks or changes the value in the master? that way users can still inline add into the detail list page.
Cheers,

J