0

I have a scriptlet in the ASPX page as below. When I browse to this page, the script debugger appears saying "Micosoft JScript runtime error: Object expected". I marked line with //<--error here. I removed everything and only left $(function(){}); It still complained about Object Expected. Do you know why? Thanks.

<fieldset>
    <button id="Case5" name = "Case5" class="wizard" title="click here to select the case">
    Case 5 - AAA </button><br />
    <button id="Case6" name = "Case6" class="wizard" title="click here to select the case">
    Case 6 - BBB </button><br />
</fieldset>

<script language="javascript" type="text/javascript">
$(function () { //<--error here
    (":button").click(function () {
        appendSelection(this);
    });
});

function appendSelection(btn) {
    //ToDo: append the selected value to the hyperlink

    var caseNumber = btn.id;
    switch (caseNumber) {
       ....
    }
}

In the Site.Master the script libraries are

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/jquery-ui.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/i18n/jquery-ui-i18n.min.js" type="text/javascript"></script>
<script src="http://jquery-ui.googlecode.com/svn/tags/latest/external/jquery.bgiframe-2.1.1.js" type="text/javascript"></script>


<script src="<%: Url.Content("~/Scripts/ui/jquery.ui.datepicker.js") %>" type="text/javascript"></script>
<script src="<%: Url.Content("~/Scripts/datetimepicker_css.js") %>" type="text/javascript" ></script>
<script src="<%: Url.Content("~/Scripts/lang/calendar-en.min.js") %>" type="text/javascript"></script>
<script src="<%: Url.Content("~/Scripts/json2.js") %>" type="text/javascript"></script>
<script type="text/javascript">var appRoot =  '<%:Url.Content("~/")%>'</script>
<script src="<%: Url.Content("~/Scripts/MyApp.js") %>" type="text/javascript"></script>
1
  • You're probably missing the dollar sign in front of (":button"). Commented Aug 9, 2011 at 17:17

2 Answers 2

4
(":button").click(function () {

should be

$(":button").click(function () {
^---missing $
Sign up to request clarification or add additional context in comments.

Comments

0

I think your issue is that you have a minor issue in your javascript and need to use the '$' to invoke jQuery in your selector.

This:

(":button").click(function () {
    appendSelection(this);
});

Needs to use jQuery for the selector as this:

$(":button").click(function () {
    appendSelection(this);
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.