1.11M Members

How to pass combobox values to variable php?

 
0
 

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?

 
0
 

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

Form:

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

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

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

MyPage.php:

$selectedOption = $_POST["mySelect"];
// Do something
 
0
 

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.

Question Answered as of 1 Year Ago by AleMonteiro
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: