<select id="facetList" style="width:120px;" class="text ui-widget-content ui-corner-all">
<?php
foreach($claAddArray as $k => $v)
{
echo "<option value=\"$k\">$v</option>";
}
?>
</select>
$("#btnSubmit").click(function() {
var $fId = ?????????????????
});
The value of the selected element can be found by using the value property on the selected element that defines the list. This property returns a string representing the value attribute of the <option> element in the list. If no option is selected then nothing will be returned.
PHP 8 Get Single Selected Values of Select Box php if(isset($_POST['submit'])){ if(! empty($_POST['Fruit'])) { $selected = $_POST['Fruit']; echo 'You have chosen: ' . $selected; } else { echo 'Please select the value. '; } } ?>
jQuery's .val() will return the currently selected option's value if run on the select list itself. In your case $("#facetList").val();
use $("#facetList option:selected").text();
for the text of the option tag.
document.getElementById('facetList').options[document.getElementById('facetList').selectedIndex].value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With