Use that code.
If you want to get text that's in the you can do that via javascript on just
select department_name from Department where dept_ID = $_POST['dname']
And the code should look like this
<select name="dname">
<?php
$data = @mysql_query("select * from Department");
while ($row = mysql_fetch_assoc($data))
{
$id = $row['dept_ID'];
$dname = $row['department_name'];
echo '<option value='.$id.'>'.$dname.'</option>'."\n";
}
?>
</select>
Personal tip, instead of dname call it dep_id.