Hazes
Hazes

Reputation: 11

Post drop down select value in HTML form

I am trying to get drop down select value posted upon send.

Markup

<select name="taskOption">
<option value="1">First</option>
<option value="2">Second</option>
<option value="3">Third</option>
</select>

php

$selectOption = $_POST['taskOption'];
                    {
                      $message.=$value.'<br>';
                    }
                    $message.='

What am I doing wrong?

Upvotes: 0

Views: 804

Answers (2)

Junius L
Junius L

Reputation: 16122

you need to use post in your form, method="post"

if(isset($_POST['submit'])){
   $dropdwon = $_POST['taskOption'];
   //code here
 }

Upvotes: 0

Taursus
Taursus

Reputation: 101

Is this what you're trying to do?

if(!empty($_POST['taskOption']))
{
    $value = $_POST['taskOption'];
    $message.=$value.'<br>';
}

Upvotes: 2

Related Questions