RE: follow upBrian, This appears to be used to set the 'selected' item in a dropdown list to the target (the target in this case is 'ItemName'). The e.selectindex is used to identify the item one wants among the list. The e.options.length is used to allow a variable length list. If you 'know' that you have only six items in the list, then you can indeed set the terminus of the FOR loop to 6. Usually code is written to allow reuse, and this allows its use in the more general variable length list, as opposed to the fixed length.
If you're getting an 'object not defined' in the SET command, then the script doesn't understand the object WEB, or you have the OPTION EXPLICIT switch set, and have not declared E as an object (e.g.; DIM E AS OBJECT). Inasmuch as the script doesn't understand another property (.length) of E, then I would go for the failure to declare E as an object. To sum up, the subroutine is used to identify the requested item (ItemName)'s position in the dropdown list. I would have used a FUNCTION to return the position, but that's another story. . . Neal ----- Original Message ----- From: Bennett, Brian To: '[email protected]' Sent: Friday, July 06, 2007 11:46 AM Subject: [Talk] Drop Down Code Since I am not a programmer and each new script or task is a new adventure in misery is there anyone who can explain this code in layman terms? Sub GetListItem(ItemName As String) Set e = Web.Selected For i = 0 To e.options.length OptName = e.options(i).innerHTML If ItemName = e.options(i).innerHTML Then e.selectedindex = i Exit Sub End If Next End Sub This is the code example from the HTML dropdown question in V. talk archives. I've got the first part working but get an object not defined error at "Set e=" and also fail at "For i=" I'm guessing that For i = 0 to e.options.length would read For i = 0 to 6, Since that is the number of choices on the dropdown I am working with? Thanks. Brian Bennett Systems Analyst Affinity Health Systems Clinic Billing 628-9055 [EMAIL PROTECTED]
