469,290 Members | 1,898 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,290 developers. It's quick & easy.

Events for select tag or use submit button?

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

Jul 19 '05 #1
6 8562
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.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


"Rich" <an*******@discussions.microsoft.com> wrote in message
news:00****************************@phx.gbl...
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

Jul 19 '05 #2
See events here. I can't comment on which ones are made-up-MS-only events
and which are W3C official.
http://msdn.microsoft.com/library/de...ds/close_0.asp

This is a client-side question though, so you should post to a browser group
or a client-side scripting group.

Ray at work

"Rich" <an*******@discussions.microsoft.com> wrote in message
news:00****************************@phx.gbl...
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

Jul 19 '05 #3
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
-----Original Message-----
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

.

Jul 19 '05 #4
<select onchange="alert(this.selectedIndex);alert(this.val ue);">

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

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
Jul 19 '05 #5
"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote:
However this has nothing to do
with ASP... please see a client-side scripting group.
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote This is a client-side question though,
so you should post to a browser group
or a client-side scripting group.
http://www.aspfaq.com/5001

Ray at work



"Rich" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl... 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

Jul 19 '05 #6
OK. Yes I got it (not the solution to my problem) - goto
client side scripting.

-----Original Message-----
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 notwork:
test.itemselected, test.selected, test.selecteditem,
test.index

Any ideas which what attribute would yield the selected
item?

Thanks,
Rich
-----Original Message-----
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 submitbutton?

Thanks,
Rich

.

.

Jul 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by EviL KerneL | last post: by
1 post views Thread by fig000 | last post: by
4 posts views Thread by blue | last post: by
3 posts views Thread by David Beardsley | last post: by
1 post views Thread by mpaine | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.