I am trying to have one of the values in my list selected. I also have a hidden field which I have to match the values in the option of the selection. If it finds one then this has to be selected.
This is the code I have.Hidden field html code.
<input type="hidden" id="supp" name="supp" value="<?php echo $_POST['suppliers'];?>" />
My js:
<script type="text/javascript">
$(document).ready(function() {
var addSelected = $('#supp').val();
$("#suppliers option[value='" + addSelected + "']").attr("selected","selected");
console.log(addSelected);
});
</script>
The code above is not working.
addSelected?