In Visual Basic, the standard combo box lets you store an Index to its data. For instance, a user would see in the list an employee name but not an associated employeeID. The ID would be stored in the ItemData property of the control. To accomplish this in DHTML, use an ADO recordset to create and populate a combo box on an ASP page. Create the recordset using the standard open methods and while looping through the records add them to the combo box. Include in the loop a counter variable and add 1 to it for each loop through the records. Use the value of the counter as an Index to the value property of the combo box.
Dim iCnt rs.open sSQL, con, adOpenKeyset, adLockReadOnlyDo Until rs.EOF Set objEntry = Document.createElement("option") objEntry.Text = rs("Name") cboEmpNames.Add objEntry cboEmpNames(iCnt).Value = rs("EmployeeID") rs.MoveNext iCnt = iCnt + 1Loop
Now when a user selects the employee name in the list, you will have accessto the value property, which contains the employee ID.