Reputation: 39
I'm using the following script that works fine when I do the click function, but I need to change it so it will happen when the Web page loads. I could not find the answer to my problem searching through stackoverflow, so I would appreciate any help from anyone on how to change it.
<script language="JavaScript">
$(function() { //run on document.ready
$("#current_sessioner").click(function() { //this occurs when select 1 changes
$("#sessioner").val($(this).val());
});
});
</script>
Upvotes: 1
Views: 62
Reputation: 817
document.addEventListener('DOMContentLoaded', function(){
$("#sessioner").val($('#current_sessioner').val());
}, false);
Upvotes: 1
Reputation: 22210
Simply move it out of the click handler.
$(function () {
$("#sessioner").val($('#current_sessioner').val());
});
Upvotes: 3