DP2003 Posted May 2, 2023 Share Posted May 2, 2023 Total noob here, I'm trying to make it so that if an option on the dropdown menu is chosen, a small text will appear underneath it. Like choosing value 1 on form A will give "text answer". The dropdown menu works fine, but the switch case command wont work. Quote Link to comment https://forums.phpfreaks.com/topic/316241-help-with-dropdown-menu-integration-with-switch-case/ Share on other sites More sharing options...
ginerjm Posted May 2, 2023 Share Posted May 2, 2023 Post REAL code, not pictures of it. Nobody will do any work with that block you posted. Quote Link to comment https://forums.phpfreaks.com/topic/316241-help-with-dropdown-menu-integration-with-switch-case/#findComment-1607934 Share on other sites More sharing options...
Solution requinix Posted May 2, 2023 Solution Share Posted May 2, 2023 Is the <select> inside a <form>? Has that form been submitted? Because that's the only way PHP will be able to do this. If you want the text to appear when you change the option without submitting a form, you need Javascript... Quote Link to comment https://forums.phpfreaks.com/topic/316241-help-with-dropdown-menu-integration-with-switch-case/#findComment-1607942 Share on other sites More sharing options...
maxxd Posted May 3, 2023 Share Posted May 3, 2023 To elaborate on requinix's point, JavaScript is client-side. That means it runs in the browser, so - for example - if the user clicks on something JavaScript can catch that action and do things to the elements currently on the loaded page without reloading that page in the browser. PHP on the other hand runs on the server, so the page needs to be refreshed so the data gets back to the server and can be acted upon. If you want to run a server-side process from the client, you'll need to use AJAX (today, the fetch() JavaScript function) to send the client-side information to the server for processing. Quote Link to comment https://forums.phpfreaks.com/topic/316241-help-with-dropdown-menu-integration-with-switch-case/#findComment-1607963 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.