0

How to create dynamic dropdown list using php excluding jquery, MySQL and Ajax?

In first dropdown i want to give options as 1 2 3 4 and in second dropdown i gave options as cat dog cow and giraffe. So if i select 1 from first dropdown then it must show only one option from second dropdown i.e. cat. Likewise if 2 then cat and dog. If 3 then cat dog and cow. And if 4 then cat dog cow and giraffe. How it should be done?? The solution should not contain any MySQL, Ajax, jquery and any other language. ONLY PHP

14th Jan 2017, 8:08 PM
Rohit Mamidwar
Rohit Mamidwar - avatar
1 Respuesta
+ 1
Yuo can evaluate if the post method is not empty to check if the user selected an entry in the first dropdown. store the values of first and second dropdown menu. Check which entry was submitted and reload the page with an edited set of options for the second dropdown. Store the value of the first dropdown in a Session variable so that if it's not empty, you know that the user made the first selection. you could achieve the same using JavaScript for editing the menus content and submit only once the user choice via php. it would avoid reloading the page on every interaction improving user experience.
14th Jan 2017, 8:23 PM
seamiki
seamiki - avatar