tags:

views:

60

answers:

5
<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...

A: 

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?

Nick Craver
Crockford advises against providing the "type" attribute at all.
Pointy
@Pointy - Who? It's a required attribute: http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.1
Nick Craver
Douglas Crockford - http://javascript.crockford.com/script.html
Pointy
@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
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
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
@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
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
A: 

should just be

$(function() {
  $("#SearchFor").change(function() {
                alert($(this).val());
        });
    });
Pointy
+3  A: 

Your document.ready statement is incorrect. Should be:

$(document).ready(function() { 

    ...

});
KP
oh /facepalm thanks :)
shogun
While the other two answers are correct, this one actually answers the question.
TheJuice
Yeah extra set of eyes always helps...
KP
A: 

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

$(document)

Notice the parenthesis

Cody Caughlan
+1  A: 

You wrote

$document.ready(function() {

But should be this instead:

$(document).ready(function() {
Seb