2

I want an easy way to store the number selected from the drop down list in a variable. How can I achieve this ? The drop down list is dynamic.

thanks

$results = $handle->query("SELECT * FROM id
 WHERE test  = '".$pull ."';");

echo "<html>";
echo "<body>";
echo "<select name='id'>";
   while($table = $results->fetchArray()){
      $tab= $tabe['ic'] -1;
      $b = "1" . $table_ ;
      echo '<option value="'.$tab.'">'.$tab.'</option>';
   }
echo "</select>";
echo "</body>";
echo "</html>";
?>
0

1 Answer 1

2

You can get the selected value as following.

console.log($("select").val());
Sign up to request clarification or add additional context in comments.

2 Comments

How does that work ? Like where do I put this in my current code. I am pretty new to all this.
@VHDLprog If you control this value, my answer is located in <script> tag, but if you don't control this and want to submit this data, my answer is not used, and you can move your select tag into form tag and submit that form.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.