Listbox OnChange

Author Message
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)
0
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
 
#1
    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)
    0
    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
     
    #2
      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)
      0
      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?
       
      #3
        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)
        0
        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"
         
         
        #4
          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)
          0
          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.
           
          #5

            Online Bookmarks Sharing: Share/Bookmark

            Jump to:

            Current active users

            There are 0 members and 1 guests.

            Icon Legend and Permission

            • 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
            • Read Message
            • Post New Thread
            • Reply to message
            • Post New Poll
            • Submit Vote
            • Post reward post
            • Delete my own posts
            • Delete my own threads
            • Rate post

            2000-2012 ASPPlayground.NET Forum Version 3.9