How to rewrite the Jquery dynamic selection box script for 5 selection boxes?
<p>I am trying to create dynamic selection boxes with Jquery.</p>

<p>Due to requirements, I have 5 selection boxes with similar Class contents e.g. Class A, Class B, Class C, etc. I have another 5 Student selection boxes besides each of the Class selection boxes. </p>

<p>So the idea is that when I select a class selection box, javascript will check on the selection and proceed to send the selection value using GET action, and return the contents for my Student selection box.</p>

<p>I already have a working script. But it is only working for one Class selection box, and if I need to have it running for the rest of the 4 Class selection boxes, I will have to create 4.js script with the different values. </p>

<p>May I know is there any way that I could just use 1 js and works for all the 5 Class selection boxes? Maybe a loop, or etc?</p>

<p>Working js for 1 selection box:</p>

<pre><code>function class_change() {
    $('#class1').change(update_students);  
        // the rest of the class sel boxes are named as #class2 #class3, etc.
}

function update_students() {
    var class = $('#class1').val();
    var seat = $('#seat1').val();   
    $.get('getStuds.php?seatno='+seat+'&amp;class='+class, showStudents);
}

function showStudents(result) {
    $('#show_student1').html(result);
}

$(document).ready(class_change);
</code></pre>

<p>Thank you very much.</p>
