So I'm trying to store the selected <option></option> tags into an array. I've searched everywhere and can't find any "Good" way of doing it.
<form action='most-liked.php'>
<select multiple name='choose-category' style='display: inline-block;'>
<?php
$allCategories = ["All", "Sport", "Automotive", "Comedy", "Misc"];
$htmlOutput = "";
$i=0;
for($i;$i<sizeof($allCategories);$i++)
{
$htmlOutput .= "<option value='".$allCategories[$i]."'>".$allCategories[$i]."</option>";
}
echo $htmlOutput;
?>
</select>
</form>
I was wondering if there is a way of adding the selected options into the array on the fly without reloading the whole page...E.g when they choose one of the <option>'s it's value will stored. Im thinking there may be a way of doing this with jQuery?
I was thinking maybe using a $_GET[] or something. But not too sure how I'd do it.
GETorPOSTmethod, which can be done by either submitting a form, or using Ajax.