How can i populate the values in the drop down(second drop down) from the select query on choosing
the option from the first drop down ?

First Drop Down : Listing out all the "department name" using select query.
Second Drop Down : Now, i need the output to list out all the "professors name" in the respective departments on the basis of the first drop down option.

Thanks in advance. Much Appreciated your help.

There are a variety of ways to address this.

A typical approach is to use server-side scripting to connect to a data source and get the results of a query that depend on the choice selected in the first drop down. When the user clicks on teh first selection, there is a post back to the page where you would take the value selected, peform a query, then build the list of items for hte second drop down and display back to the user.

Another approach can be done using AJAX where there is no post back. When the user selects an option from the first drop down, you send an AJAX request to a page that queries your data source and returns the result back to Script.