I’m trying to redo this in jQuery:
<script language="JavaScript" type="text/javascript">
var thisIsSelected = '<?php echo $_POST['image']; ?>';
var sel1= document.getElementById('image');
sel1.value = thisIsSelected;
</script>
But I seem to keep breaking it lol
Basically I want jQuery to check if $_POST[‘image’] exists and if so make it selected on the form. I’m assuming if it’s possibly with javascript, jquery can do it easier 😉
You can set the value using
.val()in jQuery, like this:The
$(function() { });wrap is so the code executes ondocument.ready, when all the elements are there and ready. If the value doesn’t exist in the<option>list, the.val()will just have no effect.