0
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>System Toolbox</title>
    <script src="../../Scripts/jquery-1.3.2.js" type="text/javascript" />
    <script type="text/javascript">

        $document.ready(function() {

            $("#SearchFor").change(function() {
                    alert($(this).val());
            });
        });

    </script>
</head>
<body>
    <div>
        Search for: <select name="SearchFor" id="SearchFor">
            <option value="company">Company</option>
            <option value="user">User</option>
            <option value="bundle">Bundle</option>
            <option value="course">Course</option>
        </select>
        <div id="SearchType"></div>
    </div>
</body>
</html>

No javascript errors per firebug...

Charles Sprayberry
  • 7,741
  • 3
  • 41
  • 50
MetaGuru
  • 42,847
  • 67
  • 188
  • 294

5 Answers5

4

Your document.ready statement is incorrect. Should be:

$(document).ready(function() { 

    ...

});
KP.
  • 13,218
  • 3
  • 40
  • 60
1

You wrote

$document.ready(function() {

But should be this instead:

$(document).ready(function() {
Seb
  • 24,920
  • 5
  • 67
  • 85
0

Try this instead:

$(function() { //Shortcut for $(document).ready();
   $("#SearchFor").change(function() {
     alert($(this).val());
   });
});

Also, best to use script tags like this still:

<script src="../../Scripts/jquery-1.3.2.js" type="text/javascript"></script>

See this question for more detail: Why don’t self-closing script tags work?

Community
  • 1
  • 1
Nick Craver
  • 623,446
  • 136
  • 1,297
  • 1,155
  • Crockford advises against providing the "type" attribute at all. – Pointy Feb 04 '10 at 20:28
  • @Pointy - Who? It's a required attribute: http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.1 – Nick Craver Feb 04 '10 at 20:31
  • @Pointy - While that's mostly good advice, I wouldn't leave out the type attribute. Simple rule for me: Having it won't cause any issues, *not* having it can (and **will** in older browsers). – Nick Craver Feb 04 '10 at 20:46
  • The reason it's problematic is that you've got to worry about what your server is going to return. In other words, the attribute on the tag second-guesses the MIME type that'll be returned in the HTTP request to actually fetch the script. In my opinion the attribute on the tag was simply a design mistake. – Pointy Feb 04 '10 at 21:00
  • Also, since Netscape 2 the default interpretation of script content has been Javascript, so there's no realistic concern with "older browsers". If you find a browser where the default type isn't Javascript or where the lack of the attribute fails, I suspect that a vast number of other things would be likely to fail too. – Pointy Feb 04 '10 at 21:01
  • @Pointy - I can't put it better than this: http://weblogs.asp.net/bleroy/archive/2007/09/17/should-i-use-a-type-attribute-on-script-tags.aspx pay attention to the comments for a lot of great points. – Nick Craver Feb 04 '10 at 22:39
  • Well the conclusion in that article is "be standards-compliant, oh except don't". The attribute is required, but the standards-compliant values don't work. Again, the whole thing seems like a mistake, so slavish standards-compliance seems pointless to me. *Chacun à son goût.* – Pointy Feb 05 '10 at 00:24
0

should just be

$(function() {
  $("#SearchFor").change(function() {
                alert($(this).val());
        });
    });
Pointy
  • 405,095
  • 59
  • 585
  • 614
0

$document is not a valid reference to a jQuery object, try

$(document)

Notice the parenthesis

Cody Caughlan
  • 32,456
  • 5
  • 63
  • 68