Josh K
Josh K

Reputation: 562

PHP: Implementation Question with Dynamic dropdown menus

This is what I want my site to do:
1. User fills in some drop down menus
2. User clicks "Update Button"
3. Old Drop downs are disabled (but still visible), and new drop downs appear below with options based on the first drop down menus (in a way that i specify)
4. Repeat 1-3 a few times
5. User submits Data

My starting point I have been using is a page that sends POST data to itself, each drop down selection is saved into a var(ie. $A1 = $_POST[A_First]) and the new drop downs are populated with these vars (using a function i made). The page works nicely without disabling the Previous menus, but once i try to do that i run into problems (since disabled tables cannot be accessed via $_POST)

Does anyone have an idea on where i can look for a solution? Again, right now I have the menus, and the update button creating new menus, but it is only good if a user goes through the natural flow, If changes are made then errors can occur. I am looking for a way to stop a user from breaking the flow by disabling the previous menus.

Thanks

Upvotes: 0

Views: 407

Answers (2)

Moot
Moot

Reputation: 51

On your select html element, specify the "readonly" attribute. The dropdown will appear on screen and the value submitted via form posting, but will not be modifiable by the user.

Upvotes: 0

Jonathan Kuhn
Jonathan Kuhn

Reputation: 15311

if you add session_start() to the top of your page you can store the previous form submission into the session array $_SESSION. sessions are made to store data between page loads while someone is on your site. You could then loop through anything saved in the sessions and re-display them disabled.

The other option would be to simply put any previous drop downs into both the disabled drop down and hidden form variables so they submit with your form with the value previously selected.

Upvotes: 1

Related Questions