I have the following snippet from HTML:
<div id="result" class = "hide">
<select id = "selectIngredients">
<option>Choose a recipe</option>
<option value="Carrot">Carrot</option>
<option value="Cabbage">Cabbage</option>
<option value="Broccoli">Broccoli</option>
</select>
<button class="btn" onClick="viewRecipe()"> View Recipe</button>
</div>
I am trying to use some PHP to get the value chosen when the button is clicked. Is this possible without having it in a form?
When I do the following it isn't working.
$selected_val = $_POST['selectIngredients']; // Storing Selected Value In Variable
echo "You have selected :" .$selected_val; // Displaying Selected Value
}