Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Visual Basic
Expertise: Beginner
Jan 28, 1999



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Create a DHTML Combo Box

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, adLockReadOnly

Do Until rs.EOF
        Set objEntry = Document.createElement("option")
        objEntry.Text = rs("Name")
        cboEmpNames.Add objEntry
        cboEmpNames(iCnt).Value = rs("EmployeeID")
        iCnt = iCnt + 1
Now when a user selects the employee name in the list, you will have access to the value property, which contains the employee ID.
Mike Gasperino
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date