We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,439 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

How to pass combobox values to variable php?

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?

2
Contributors
2
Replies
1 Day
Discussion Span
3 Months Ago
Last Updated
20
Views
Question
Answered
guilherme.carvalho.9250
Light Poster
28 posts since Jul 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 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
AleMonteiro
Master Poster
752 posts since Aug 2010
Reputation Points: 129
Solved Threads: 140
Skill Endorsements: 25

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.

guilherme.carvalho.9250
Light Poster
28 posts since Jul 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0
Question Answered as of 3 Months Ago by AleMonteiro

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.0600 seconds using 2.69MB