I would like to be able to insert a dropdown box where I have specified with option that should be selected as default.
Something like the code below, where the first should insert a dropdown box with default selected "BBB" (val2 ~ BBB).
This JSFiddle almost does what I need, but the problem with it is:
- it should be possible to define which option should be selected as default
- the JavaScript/JQuery should be generic and not hardcoded to a specific ID
What I would like is something like this
<select>
<script type='text/javascript'>
insert_dropdown("val2");
</script>
</select>
<select>
<script type='text/javascript'>
insert_dropdown("val3");
</script>
</select>
How should such a function be made?