hello I wanted to know whats the best way to send sql results to a javascript function. I have two dropdown lists and i want to populate the second one according to the first one. both dropdown lists arre populated from a mysql database. fillcourses is the javascript function but i dont know how to pass the result array to it.
$db = new Db();
$db->query('SELECT idDepartment,name FROM department');
<select name="department" onchange=" fill_courses (
SELECT courseNumber,courseId FROM courses
WHERE Department_idDepartment = document.addCourse.department.selectedIndex.value); ">';
while ($row=$db->nextRow())
{
echo'<option value="' . $row['idDepartment'] . '">' . $row['name'] . '</option>';
}
echo'</select>
<select name="courses">
</select>