Hello everyone, I'm new to php and i'm developing a website for a school project. I need to implement a combobox with some options, for exemple, if I choose "Alimentation" it appears a table with the specific fields for this option and If I choose other option it appears a table with specific fields for it etc.
The combobox in html has values, if I pass this values to a php variable I think I can do this system
Ex html: <option value = "1"> Alimentation</option>
Ex php: $option1 = the value on the combobox

How can I do this? Do I need to do all of this in php?

Re: How to pass combobox values to variable php? 80 80

You need to post your form and then get the value, something like this:


<form action="MyPage.php" method="post">

    <select name="mySelect">
        <option value="1">My First Option</option>

    <button type="submit">Submit</button>


$selectedOption = $_POST["mySelect"];
// Do something
Re: How to pass combobox values to variable php? 80 80

Hi thankyou for giving me an exemple of what i want to do and sorry for not reply earlier. That's is what i was looking for thankyou.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.