Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Listbox OnChange

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,46512
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> Listbox OnChange
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Listbox OnChange - 4/30/2007 5:28:26 PM   
  griffjj

 

Posts: 3
Score: 0
Joined: 4/30/2007
Status: offline
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
 
 
Post #: 1
 
 RE: Listbox OnChange - 5/1/2007 12:59:12 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
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.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to griffjj)
 
 
Post #: 2
 
 RE: Listbox OnChange - 5/1/2007 1:35:56 AM   
  griffjj

 

Posts: 3
Score: 0
Joined: 4/30/2007
Status: offline
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?

(in reply to ebgreen)
 
 
Post #: 3
 
 RE: Listbox OnChange - 5/5/2007 7:45:18 AM   
  softip

 

Posts: 1
Score: 0
Joined: 5/5/2007
Status: offline
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"

(in reply to griffjj)
 
 
Post #: 4
 
 RE: Listbox OnChange - 5/9/2007 4:00:15 AM   
  griffjj

 

Posts: 3
Score: 0
Joined: 4/30/2007
Status: offline
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.

(in reply to softip)
 
 
Post #: 5
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> Listbox OnChange Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts