Display second dropdown list if a value is selected in the first dropdown (using variables)?
<p>Is there any way I can select a certain value in a dropdown list and according to that selection display a second dropdown list?
I know how to do it with just normal words, but what if I use variable names?</p>

<pre><code>University Name: &lt;select name="university" id="university"&gt;
&lt;?php 
    while($row = mysql_fetch_array($uniName)) {
        echo "&lt;option&gt;" . $row['uni_name'] . "&lt;/option&gt;"; 
    }
?&gt; 
&lt;/select&gt;
&lt;br/&gt;
Course Name: &lt;select name='course' id='course'&gt;
&lt;?php 
    while($row = mysql_fetch_array($courseNames)) {
        echo "&lt;option&gt;" . $row['course_name'] . "&lt;/option&gt;"; 
    }
?&gt;
&lt;/select&gt;
</code></pre>

<p>So as you can see, in the first dropdown list I've added all the retrieved university names from my database. I did the same for the courses as well.</p>

<p>Now how can I modify the code below:</p>

<pre><code>$(document).ready(function() {
    $('#course').hide();

    $('#university').change(function () {
        if ($('#university option:selected').text() == "Harvard University"){
            $('#course').fadeIn('slow');
        }
        else { 
            $('#course').fadeOut('slow');
        }
    });
});
</code></pre>

<p>Instead of "Harvard University", I want to put a variable there according to what the user has selected. Something like $university_name and then I'll create a new query and display only the courses belong to a certain $university_name.</p>
