I wrote a PHP code for prepare jQuery function, which can select multipal values from the html multi select box.
there are different campaigns and it have separate question sets, the one campain has many question sets. below code returns the output as
$('#q9 select').val('2');
$('#q10 select').val('2');
$('#q10 select').val('1');
but i need this output as
$('#q9 select').val(['2']);
$('#q10 select').val(['2','1']);
to select multipal items, can anyone help please, thank you...
<script>
$(function(){
<?php
foreach ($selectdefaults as $s):
?>
$('#q<?php echo $s['campsetjoin']['campid'];?> select').val('<?php echo $s['campsetjoin']['setid'];?>');
<?php
endforeach;
?>
});
</script>