griffjj
-
Total Posts
:
3
- Scores: 0
-
Reward points
:
0
- Joined: 4/30/2007
-
Status: offline
|
Listbox OnChange
Monday, April 30, 2007 6:28 PM
( permalink)
I'm trying to trigger an OnChange event for an HTML listbox on an ASP page. I want to call a VBScript procedure any time I select a new value from the listbox. This seems like it should be easy based on what I've read, but I can't get it to do anything. I'm just learning how all of this stuff works, so I'd appreciate any help. I'm getting desperate. Here is the code for my ASP test page: <%@ LANGUAGE="VBScript" %> <% Option Explicit %> <html> <head> <title>Test</title </head> <body> <form name="test" method="post" action="test.asp"> <select onChange="TestSub1"> <option value="1">Test1</option> <option value="2">Test2</option> </select> </form> </body> </html> <script> Sub TestSub() response.redirect("http://www.google.com") End Sub </script> Thanks, Jim
|
|
|
|
ebgreen
-
Total Posts
:
8227
- Scores: 98
-
Reward points
:
0
- Joined: 7/12/2005
-
Status: offline
|
RE: Listbox OnChange
Tuesday, May 01, 2007 1:59 AM
( permalink)
I don't do ASP, but I'll give it a stab. This is your function definition: Sub TestSub() So the sub is defined with the name TestSub. Here is your onChange call: <select onChange="TestSub1"> You are telling it to execute TestSub1. There is no such sub.
|
|
|
|
griffjj
-
Total Posts
:
3
- Scores: 0
-
Reward points
:
0
- Joined: 4/30/2007
-
Status: offline
|
RE: Listbox OnChange
Tuesday, May 01, 2007 2:35 AM
( permalink)
Oops, I didn't mean to copy that version of the code. Sorry, it was late when I posted and I had been struggling with this same stupid problem this for about eight hours. But that actually demonstrates something else weird that I noticed. When I had my procedure defined as TestSub and the OnChange event indicated TestSub1, I did not get any compilation error. The page behaved exactly as it did when both pieces indicated TestSub (the dropdown appeared fine on the page, but selecting different values from it did nothing). It's as if the OnChange element of the SELECT statement is getting completely ignored. I must be missing something obvious. Anybody have any ideas? Please?
|
|
|
|
softip
-
Total Posts
:
1
- Scores: 0
-
Reward points
:
0
- Joined: 5/5/2007
-
Status: offline
|
RE: Listbox OnChange
Saturday, May 05, 2007 8:45 AM
( permalink)
Method Response.Redirect is for ASP only, but you are using tags of VBscript, so you have to use vb method. heres the vb method. Window.Location.Href ="www.yourdomain.com"
|
|
|
|
griffjj
-
Total Posts
:
3
- Scores: 0
-
Reward points
:
0
- Joined: 4/30/2007
-
Status: offline
|
RE: Listbox OnChange
Wednesday, May 09, 2007 5:00 AM
( permalink)
I tried softip's suggestion, but it's still behaving the same way. Actually I can't get any events to work so I must be completely misunderstanding how this is supposed to work. I've tried OnChange for listboxes, OnClick for buttons, and OnClick for hyperlinks. No matter what I do, my events are never getting triggered. This is really starting to pi$$ me off.
|
|
|
|