how to call jquery function on page load
<p>in my php page i have four dropdown list and i want first and second dropdown list selected and those are coming from database but i am getting problem in selecting second dropdown. it's working when i change value of first dropdown so, it's working on value change but not when page load and my function for it is $.streamSelection.</p>

<pre><code>&lt;script&gt;
    $(document).ready(function() {
        $('#&lt;?php echo $stream;?&gt;').prop('selected', true);
        $('.sidebar-menu .system').addClass('active');
        $('.sidebar-menu .system .student').addClass('active');
        $(".sidebar-menu .system").tree();
        $('#streams').change(function() {
            $('#branches').html("&lt;option value=''&gt;-- Select --&lt;/option&gt;");
            $('#batches').html("&lt;option value=''&gt;-- Select --&lt;/option&gt;");
            $('.divAfter').hide();
            $('.divBefore').show();
            $('.semesterAfter').hide();
            $('.semesterBefore').show();
            $('.btnAdd').hide();
            $('.btnExcel').hide();
            $('.studList').hide();
            if ($(this).val() == '') {} else {
                $.when($.streamSelection($(this).val())).then($.listSemester($(this).val()));
            }
        });
        $('#branches').change(function() {
            $('#batches').html("&lt;option value=''&gt;-- Select --&lt;/option&gt;");
            $('.divAfter').hide();
            $('.divBefore').show();
            $('.semesterAfter').hide();
            $('.semesterBefore').show();
            $('.btnAdd').hide();
            $('.btnExcel').hide();
            $('.studList').hide();
            if ($(this).val() == '') {} else {
                $.branchSelection($(this).val());
            }
        });
        $('#batches').change(function() {
            if ($(this).val() == '') {
                $('.divAfter').hide();
                $('.divBefore').show();
                $('.semesterAfter').hide();
                $('.semesterBefore').show();
                $('.btnAdd').hide();
                $('.btnExcel').hide();
                $('.studList').hide();
            } else {
                $('.divBefore').hide();
                $('#division').val('');
                $('.divAfter').show();
            }
        });
        $('#division').change(function() {
            $('.studList').hide();
            $('.semesterAfter').hide();
            $('.semesterBefore').show();
            $('.btnAdd').hide();
            $('.btnExcel').hide();
            if ($(this).val() != '') {
                $('.semesterBefore').hide();
                $('#sem').val('');
                $('.semesterAfter').show();
            }
        });
        $('#sem').change(function() {
            $('.btnAdd').hide();
            $('.btnExcel').hide();
            $('.studList').hide();
            if ($(this).val() != '') {
                $.when($('.btnAdd').attr('href', 'add.php?streamId=' + $('#streams').val() + '&amp;branchId=' + $('#branches').val() + '&amp;batchId=' + $('#batches').val() + '&amp;divisionId=' + $('#division').val() + '&amp;semId=' + $('#sem').val()))
                    .then($('.btnExcel').attr('href', 'studExcel.php?streamId=' + $('#streams').val() + '&amp;branchId=' + $('#branches').val() + '&amp;batchId=' + $('#batches').val() + '&amp;divisionId=' + $('#division').val() + '&amp;semId=' + $('#sem').val()))
                    .then($('.btnAdd').show())
                    .then($.studentList($('#streams').val(), $('#branches').val(), $('#batches').val(), $('#division').val(), $('#sem').val()));
            }
        });
    });
    $.streamSelection = function(selStreamId) {
        $.ajax({
            url: "searchBranch.php",
            data: {
                branch: &lt;?php echo $branch;?&gt;,
                streamId: selStreamId
            },
            success: function(data) {
                $('#branches').html(data);
            },
            error: function(error) {
                alert(error);
            }
        });
    }
&lt;/script&gt;
</code></pre>

<p>and my full code is with html is.</p>

<pre><code>&lt;?php session_start();
if(isset($_SESSION['userId'])) {
    require_once('../../config/connection.php');
    $streamResult = mysql_query("SELECT * FROM streams");
    if(isset($_GET['streamId'])) {
        $stream=$_GET['streamId'];
    }
    if(isset($_GET['branchId'])) {
        $branch=$_GET['branchId'];
    }
    if(isset($_GET['batchId'])) {
        $batch=$_GET['batchId'];
    }
    if(isset($_GET['divisionId'])) {
        $division=$_GET['divisionId'];
    }
    if(isset($_GET['semId'])) {
        $sem=$_GET['semId'];
    }
?&gt;
    &lt;!DOCTYPE html&gt;
    &lt;html lang="eng"&gt;
        &lt;head&gt;
            &lt;meta charset="UTF-8"&gt;
            &lt;title&gt;Students | Admin | ITBiz ERP&lt;/title&gt;
            &lt;meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'&gt;
            &lt;link rel="stylesheet" type="text/css" href="../public/css/bootstrap.min.css" /&gt;
            &lt;link rel="stylesheet" type="text/css" href="../public/css/font-awesome.min.css" /&gt;
            &lt;link rel="stylesheet" type="text/css" href="../public/css/ionicons.min.css" /&gt;
            &lt;link rel="stylesheet" type="text/css" href="../public/css/bootstrap3-wysihtml5.min.css" /&gt;
            &lt;link rel="stylesheet" type="text/css" href="../public/css/AdminLTE.css" /&gt;
            &lt;link rel="stylesheet" type="text/css" href="../public/css/admin.custom.css" /&gt;
            &lt;link rel="shortcut icon" href="../../views/public/img/favicon.ico"&gt;
            &lt;script src="../public/js/jquery.min.js"&gt;&lt;/script&gt;
            &lt;!--[if lt IE 9]&gt;
                &lt;script src="../public/js/html5shiv.js"&gt;&lt;/script&gt;
                &lt;script src="../public/js/html5shiv.responsive.js"&gt;&lt;/script&gt;
            &lt;![endif]--&gt;
        &lt;/head&gt;
        &lt;body class="skin-blue"&gt;
            &lt;?php include '../public/includes/header.php';?&gt;
            &lt;div class="wrapper row-offcanvas row-offcanvas-left"&gt;
                &lt;?php include '../public/includes/sidebar.php';?&gt;
                &lt;aside class="right-side"&gt;
                    &lt;section class="content"&gt;
                        &lt;div class="page-header"&gt;
                            &lt;h7&gt;
                                Students
                                &lt;a href="#" class="btn btn-primary pull-right hide btnAdd" style="margin-left:10px;"&gt;Add&lt;/a&gt;
                                &lt;a href="#" class="btn btn-info pull-right hide btnExcel"&gt;Generate Excel&lt;/a&gt;
                            &lt;/h7&gt;
                        &lt;/div&gt;
                        &lt;!-- selection --&gt;
                        &lt;div class="row" id="addStream"&gt;
                            &lt;div class="col-lg-12"&gt;
                                &lt;?php
                                    if(isset($_SESSION['message'])) {
                                        echo
                                        "&lt;div class='alert alert-success text-center'&gt;
                                            &lt;p&gt;&lt;b&gt;".$_SESSION['message']."&lt;/b&gt;&lt;/p&gt;
                                        &lt;/div&gt;";
                                        unset($_SESSION['message']);
                                    }
                                    if(isset($_SESSION['error'])) {
                                        echo
                                        "&lt;div class='alert alert-danger text-center'&gt;
                                            &lt;p&gt;&lt;b&gt;".$_SESSION['error']."&lt;/b&gt;&lt;/p&gt;
                                        &lt;/div&gt;";
                                        unset($_SESSION['error']);
                                    }
                                ?&gt;
                                &lt;form class="" role="form"&gt;
                                    &lt;div class="col-lg-2"&gt;
                                        &lt;div class="form-group"&gt;
                                            &lt;label for="streams"&gt;Select Stream&lt;/label&gt;
                                            &lt;select name="streams" id="streams" class="form-control"&gt;
                                                &lt;option value=""&gt;-- Select --&lt;/option&gt;
                                                &lt;?php
                                                    while($streamRow = mysql_fetch_array($streamResult)) {
                                                        echo
                                                            "&lt;option value=".$streamRow[0]." id=".$streamRow[0]."&gt;".$streamRow[1]."&lt;/option&gt;";
                                                    }
                                                ?&gt;
                                            &lt;/select&gt;
                                        &lt;/div&gt;
                                    &lt;/div&gt;
                                    &lt;div class="col-lg-2"&gt;
                                        &lt;div class="form-group"&gt;
                                            &lt;label for="branches"&gt;Select Branch&lt;/label&gt;
                                            &lt;select name="branches" id="branches" class="form-control"&gt;
                                                &lt;option value=""&gt;-- Select --&lt;/option&gt;
                                            &lt;/select&gt;
                                        &lt;/div&gt;
                                    &lt;/div&gt;
                                    &lt;div class="col-lg-2"&gt;
                                        &lt;div class="form-group"&gt;
                                            &lt;label for="batches"&gt;Select Batch&lt;/label&gt;
                                            &lt;select name="batches" id="batches" class="form-control"&gt;
                                                &lt;option value=""&gt;-- Select --&lt;/option&gt;
                                            &lt;/select&gt;
                                        &lt;/div&gt;
                                    &lt;/div&gt;
                                    &lt;div class="col-lg-2"&gt;
                                        &lt;div class="form-group divBefore"&gt;
                                            &lt;label for="divisionBefore"&gt;Select Division&lt;/label&gt;
                                            &lt;select name="divisionBefore" id="divisionBefore" class="form-control"&gt;
                                                &lt;option value=""&gt;-- Select --&lt;/option&gt;
                                            &lt;/select&gt;
                                        &lt;/div&gt;

                                        &lt;div class="form-group divAfter hide"&gt;
                                            &lt;label for="division"&gt;Select Division&lt;/label&gt;
                                            &lt;select name="division" id="division" class="form-control"&gt;
                                                &lt;option value=""&gt;-- Select --&lt;/option&gt;
                                                &lt;?php
                                                    $divisionResult = mysql_query("SELECT * FROM division");
                                                    while($divisionRow = mysql_fetch_array($divisionResult)) {
                                                        echo
                                                            "&lt;option value=".$divisionRow[0]."&gt;".$divisionRow[1]."&lt;/option&gt;";
                                                    }
                                                ?&gt;
                                            &lt;/select&gt;
                                        &lt;/div&gt;
                                    &lt;/div&gt;
                                    &lt;div class="col-lg-2"&gt;
                                        &lt;div class="form-group semesterBefore"&gt;
                                            &lt;label for="semBefore"&gt;Select Semester&lt;/label&gt;
                                            &lt;select name="semBefore" id="semBefore" class="form-control"&gt;
                                                &lt;option value=""&gt;-- Select --&lt;/option&gt;
                                            &lt;/select&gt;
                                        &lt;/div&gt;

                                        &lt;div class="form-group semesterAfter hide"&gt;
                                            &lt;label for="sem"&gt;Select Semester&lt;/label&gt;
                                            &lt;select name="sem" id="sem" class="form-control"&gt;
                                                &lt;option value=""&gt;-- Select --&lt;/option&gt;
                                            &lt;/select&gt;
                                        &lt;/div&gt;
                                    &lt;/div&gt;
                                &lt;/form&gt;
                            &lt;/div&gt;
                        &lt;/div&gt;
                        &lt;!-- end selection --&gt;

                        &lt;!-- students list --&gt;
                        &lt;div class="row"&gt;
                            &lt;div class="col-lg-12"&gt;
                                &lt;div class="page-header"&gt;
                                    &lt;h6&gt;Students List&lt;/h6&gt;
                                &lt;/div&gt;
                            &lt;/div&gt;
                        &lt;/div&gt;

                        &lt;div class="studList"&gt;&lt;/div&gt;
                        &lt;!-- end students list --&gt;
                    &lt;/section&gt;
                &lt;/aside&gt;
            &lt;/div&gt;
            &lt;?php
                if(strcmp($_SESSION['role']['name'], 'admin') != 0) {
                    echo
                    $streamList = mysql_query("SELECT streams_id FROM streams where name='".$_SESSION['role']['name']."' ");
                    $streamRow = mysql_fetch_array($streamList);
                    $branchResult = mysql_query("SELECT * FROM branches WHERE streams_id=".$streamRow[0]);
                    echo
                    "&lt;script&gt;
                        $(document).ready(function() {
                            $.when($('#streams').val('".$streamRow[0]."'))
                            .then($('#streams').parent('div').parent('div').hide())
                            .then($.streamSelection($('#streams').val()))
                            .then($.listSemester($('#streams').val()));
                        });
                    &lt;/script&gt;";
                }
            ?&gt;

            &lt;script src="../public/js/bootstrap.min.js"&gt;&lt;/script&gt;
            &lt;script src="../public/js/bootstrap3-wysihtml5.all.min.js"&gt;&lt;/script&gt;
            &lt;script src="../public/js/app.js"&gt;&lt;/script&gt;
            &lt;script src="../public/js/jquery.validate.js"&gt;&lt;/script&gt;
            &lt;script src="../public/js/admin.custom.js"&gt;&lt;/script&gt;
            &lt;script&gt;
                $(document).ready(function() {
                    $('#&lt;?php echo $stream;?&gt;').prop('selected',true);
                    $('.sidebar-menu .system').addClass('active');
                    $('.sidebar-menu .system .student').addClass('active');
                    $(".sidebar-menu .system").tree();
                    $('#streams').change(function() {
                        $('#branches').html("&lt;option value=''&gt;-- Select --&lt;/option&gt;");
                        $('#batches').html("&lt;option value=''&gt;-- Select --&lt;/option&gt;");
                        $('.divAfter').hide();
                        $('.divBefore').show();
                        $('.semesterAfter').hide();
                        $('.semesterBefore').show();
                        $('.btnAdd').hide();
                        $('.btnExcel').hide();
                        $('.studList').hide();
                        if($(this).val() == '') {
                        }
                        else {
                            $.when($.streamSelection($(this).val())).then($.listSemester($(this).val()));
                        }
                    });
                    $('#branches').change(function() {
                        $('#batches').html("&lt;option value=''&gt;-- Select --&lt;/option&gt;");
                        $('.divAfter').hide();
                        $('.divBefore').show();
                        $('.semesterAfter').hide();
                        $('.semesterBefore').show();
                        $('.btnAdd').hide();
                        $('.btnExcel').hide();
                        $('.studList').hide();
                        if($(this).val() == '') {
                        }
                        else {
                            $.branchSelection($(this).val());
                        }
                    });
                    $('#batches').change(function() {
                        if($(this).val() == '') {
                            $('.divAfter').hide();
                            $('.divBefore').show();
                            $('.semesterAfter').hide();
                            $('.semesterBefore').show();
                            $('.btnAdd').hide();
                            $('.btnExcel').hide();
                            $('.studList').hide();
                        }
                        else {
                            $('.divBefore').hide();
                            $('#division').val('');
                            $('.divAfter').show();
                        }
                    });
                    $('#division').change(function() {
                        $('.studList').hide();
                        $('.semesterAfter').hide();
                        $('.semesterBefore').show();
                        $('.btnAdd').hide();
                        $('.btnExcel').hide();
                        if($(this).val() != '') {
                            $('.semesterBefore').hide();
                            $('#sem').val('');
                            $('.semesterAfter').show();
                        }
                    });
                    $('#sem').change(function() {
                        $('.btnAdd').hide();
                        $('.btnExcel').hide();
                        $('.studList').hide();
                        if($(this).val() != '') {
                            $.when($('.btnAdd').attr('href', 'add.php?streamId='+$('#streams').val()+'&amp;branchId='+$('#branches').val()+'&amp;batchId='+$('#batches').val()+'&amp;divisionId='+$('#division').val()+'&amp;semId='+$('#sem').val()))
                            .then($('.btnExcel').attr('href', 'studExcel.php?streamId='+$('#streams').val()+'&amp;branchId='+$('#branches').val()+'&amp;batchId='+$('#batches').val()+'&amp;divisionId='+$('#division').val()+'&amp;semId='+$('#sem').val()))
                            .then($('.btnAdd').show())
                            .then($.studentList($('#streams').val(),$('#branches').val(),$('#batches').val(),$('#division').val(),$('#sem').val()));
                        }
                    });
                });
                $.streamSelection = function(selStreamId) {
                    $.ajax({
                        url:"searchBranch.php",
                        data:{
                            branch:&lt;?php echo $branch;?&gt;,
                            streamId:selStreamId
                        },
                        success: function(data) {
                            $('#branches').html(data);
                        },
                        error: function(error) {
                            alert(error);
                        }
                    });
                }
                $.branchSelection = function(selBranchId) {
                    $.ajax({
                        url:"searchBatch.php",
                        data:{
                            branchId:selBranchId,
                        },
                        success: function(data) {
                            $('#batches').html(data);
                        },
                        error: function(error) {
                            alert(error);
                        }
                    });
                }
                $.listSemester = function(selStreamId) {
                    $.ajax({
                        url:"searchStream.php",
                        data:{
                            streamId:selStreamId,
                        },
                        success: function(data) {
                            $('#sem').html(data);
                        },
                        error: function(error) {
                            alert(error);
                        }
                    });
                }
                $.studentList = function(streamId,branchId,batchId,divisionId,semId) {
                    $.ajax({
                        url:"searchStudent.php",
                        data:{
                            selStreamId     :   streamId,
                            selBranchId     :   branchId,
                            selBatchId      :   batchId,
                            selDivisionId   :   divisionId,
                            selSemId        :   semId
                        },
                        success: function(data) {
                            $('.studList').html(data);
                            $('.studList').show();
                            if(data.length &gt; 0)
                                $('.btnExcel').show();
                        },
                        error: function(error) {
                            alert(error);
                        }
                    });
                }
            &lt;/script&gt;
        &lt;/body&gt;
    &lt;/html&gt;
&lt;?php
}
else
    header('location:../../');
?&gt;
</code></pre>