Jump to content

Help with dropdown menu integration with switch case


DP2003
Go to solution Solved by requinix,

Recommended Posts

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".

Screenshot_175.png

The dropdown menu works fine, but the switch case command wont work.

Link to comment
Share on other sites

  • Solution

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...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.