Retaining Dynamic Dropdowns Search options on page reload
Hi there
I have managed to set up a search facility using a couple of linked dynamic dropdowns and the data assist search wizard within a client's admin tool. Basically they make a selection from the first dropdown - this dynamically populates the second dropdown, they then make a selection from the second dropdown and hit a 'search' button. I've set up the page to be both the search and results page so when page then refreshes is displays the search facility and the results. However, the problem I'm having is getting the two dropdowns to retain their original search selections on the page reload. For example, if they select 'Car' from the first and 'Ford' from the second, when they hit the search it reloads the page with the results but the dropdowns are still displaying 'Car' and 'Ford'. I was originally able to do this when the search facility only had one dropdown as i could set a 'select value equal to' to the correct id, but it doesn't seem to work now that I'm running two linked dropdowns and the second when doesn't contain any content when initially loaded.
Just to give a little background I have three tables labelled 'Level 1', 'Level 2' and 'Level 3' and their basic structure is...
level1 contains: level1_id and level1_name (this table populates the first dropdown)
level2 contains: level2_id, level2_name and level1_id (this table populates the second dropdown)
level3 contains: level3_id, level3_name and level2_id (this table populates the search results)
I've tried a few variations...
1. No initially selected options (not even a 'Select an option') and Populate List from Array - Target list options - Leave Top set to 0. This just returns with the first value displaying in the first dropdown and the second dropdown empty.
2. The same as above but Leave Top set to 1. This just populates the second menu with an initial empty option when the first dropdown option has been chosen.
3. Setting the initially selected value of the first dropdown to <?php $row_level2['level1_id'] ?>. This dropdown is set with 'Options from Recordset - level1', 'Values - level1_id' and 'Labels - level1_name'. This just gives the same result as the first variation.
4. Same as above but additionally adding <option value=""<?php if (!(strcmp($row_level2['level2_id'], $row_level3['level2_id']))) {echo "selected=\"selected\"";} ?>></option> between the <select></select> tags of the second dropdown. This just gives the same result as the first variation.
I'm guessing it's a fairly straightforward issue that I'm missing and would be extremely grateful for any assistance.
Many thanks in advance.
Paul.