Hello,

I need some help with this function.

I have a table with data:
EMPNO ENAME GRADE
-------- ------- ---------
100 JACK A
101 JOHN B
103 TOM A

I need to create a select item that will list all the names. I want to be able to select one of the names from the drop down. I want to create a form without selecting a submit button. So, i figured I could use the onchange : this.formname.submit(). However I can't seem to understand where I am making a mistake. This is the code I've written.

<form name="empselect" action="?emp_select" method="post">
<h3>Select the Employees Name:
<select name="employee" id="employee" class="styled-select" onchange="this.form.submit()">
<option value="">Select an employee </option>
<?php foreach ($employees as $employee):?>
<option value="<?php echo($employee['empno']);?>">
<?php echo($employee['ename'].'-'.$employee['grade']);?></option>
<?php endforeach;?>
</select> </h3> <br>
<input type="hidden" name="grade" value="<?php echo $employee['grade']?>">
</form>

In the php part that was written above the form, I wrote:
if (isset($_GET['emp_select']))
{
$grade=$_POST['grade'];
echo "grade is" . $grade;
}

I am making a mistake somewhere. I need to get the grade for further processing on the form, and I needed it based on user selection of the employee's name. At this time, the only the grade of the last employee is available to $grade, also the value that i selected from the drop down immediately jumps back to the default.

Just a further explanation of my code:
1. A query retrieved the empno, name and grade.
2. The select is displaying a combination of the employeename-grade as in:
JACK-A
3. I want to select a name, and have the drop down return the employee's ID, but a hidden element submit the grade.
4. I need to program another form later in the document using the $grade value, based on the employee that I selected.
5. I do not want a separate submit button attached to the selection of the employee.

Your kind assistance is greatly appreciated.