Events for select tag or use submit button?

R

Rich

Hello,

I was just wondering if there is/are an event(s) for the
select tag, specifically like an onclick event

<p><select name="test" size="8">
<option value="zero">test1</option>
<option>test2</option>
<option>test3</option>
<option>test4</option>
</select></p>

Sub test_onclick()
msgbox test.selectedindex
End Sub

I haven't tried this, but before I spin my wheels trying
to guess the event names, are there any for the select
tag? Or do I have to call the sub/function from a submit
button?

Thanks,
Rich
 
A

Aaron Bertrand - MVP

Having an action fire based on a dropdown change is really annoying.
Especially when there is also a button there.

You can do it using the onchange() event. However this has nothing to do
with ASP... please see a client-side scripting group.
 
R

Rich

Thank you all for your replies. Actually, I did try this
successfully, but not able to select something from the
dropdownlist

Sub test_onclick()
msgbox "Clicked"
End Sub

this worked, but this did not work
Sub test_onclick()
msgbox test.selectedindex
End Sub

I guess I should have asked what the attribute is for
selecting something. I tried the following, which did not
work:
test.itemselected, test.selected, test.selecteditem,
test.index

Any ideas which what attribute would yield the selected
item?

Thanks,
Rich
 
A

Aaron Bertrand - MVP

<select onchange="alert(this.selectedIndex);alert(this.value);">

*PLEASE* follow-up in a CLIENT-SIDE forum.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,141
Messages
2,570,817
Members
47,362
Latest member
ChandaWagn

Latest Threads

Top