Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DropDown OnClick event doesn't fire 1

Status
Not open for further replies.

FancyPrairie

Programmer
Oct 16, 2001
2,917
US
I have a script that looks like this:
Code:
<script language=vbscript>
sub MyListBox_onclick()
    msgbox "here i am"
end sub
</script>

1. The event fires if I code my page like this:
Code:
<select id=MyListBox ... [COLOR=blue]onclick=MyListBox_onclick()[/color]>...</select>

2. It won't fire if I code my page like this:
Code:
<select id=MyListBox>...</select>

However, method 2 works for all other controls. Why won't it work for a list box?

I don't want to add the onclick event to the Select statement. Rather I want to assign the onclick event via code. Like this (which works for all controls except for the list box):
Code:
Dim oEvents
set oEvents = getref("MyListBox_onclick")
document.all(strListBoxName).attachEvent "onclick", oEvents
 
Use "onchange" instead of "onclick". But if you use "onclick" it still works (contrary to what you describe - I can't reproduce it anyway) only that everyone gets unpleasant experience using the page or that its performance is not what you would expected.
 
Thanks. It seems like I've always experienced the problem and assumed it to be a "feature" of list boxes. But because you said it works on your end, I revisted my code and discovered that the program I'm using to build the pages was introducing some code into the tag properties which caused my problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top