I have a javascript script that allows me to select data from drop down menus, how would I modify my script to be able to select from an array instead of just a single value?
<script type='text/javascript'>
$(window).load(function(){
$("select[value]").each(function() {
$(this).val(this.getAttribute("value"));
});
});
</script>
In the HTML code normally I would just put the value as the data from the database, and it would auto select it. But with a multi select, I have it in the database as
option1,option2,option3
And then I turn it into an array
Array
(
[0] => option1
[1] => option2
[2] => option3
)
So how would I tell my script to select each and every value in the array?