I have a dynamic drop down menu and I need to run a jquery code when the user selects an option. 

This is the jquery I need to run:

```
$(function() {

    $("select").on("change", function() {

        var value = $(this).value(); //get the selected id
        $.get("requesturl.php", {
            course: value
        }, function() {

            // do something with the response
        }, "json");

    })

})

```

This is my php code:

```
     if(User('PROFILE')=='admin' || User('PROFILE')=='parent'){

        $sql=  "SELECT id, course_period_id from schedule WHERE STUDENT_ID='$_SESSION[student_id]'";

        $result=mysql_query($sql);

        $options="";

        while ($row=mysql_fetch_array($result)) {

            $id=$row["id"];
            $course_period_id=$row["course_period_id"];
            $course= DBGet(DBQuery("SELECT title FROM course_periods WHERE course_period_id='$course_period_id'"));
            $options.="<OPTION VALUE=\"$course[1]['TITLE']\">".$course[1]['TITLE'].'</option>';

        }

        echo "<script type = 'text/javascript'>
                function populate(course)
            {
                alert('test');
             }</script>";

        echo "<SELECT id='course' name = 'course' onchange='populate(this.course)'  >
            <OPTION VALUE=0>Choose
             $options

             </SELECT>";

     }

```

I tried to run a test alert inside the jquery but nothing happened when I selected an option.

Please help me, I have no idea how to add the jquery code to my php code.