Javascript error headache: object doesn't support this property or method

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • news.onetel.net.uk

    Javascript error headache: object doesn't support this property or method

    I and my friend Karl have spent literally all day trying to find out what is
    causing my error but we are zapped of any further functionality :)

    I have a form that adds news records. You select 'City' then you select
    'Business Category' - now when you select 'Business Category' the next
    drop-down menu (business sub category) should populate with 'Business
    Sub-categories' related to the 'Business Category' but once 'Business
    Category' is selected I get the javascript error:

    Line: 98
    char: 25
    error: object doesn't support this property or method
    code: 0

    Can anyone save us?

    This is the URL: http://www.workwise-ely.org/directory/add.php

    This is the siurce: http://www.workwise-ely.org/directory/form.txt



    On the 'business_categ ory' I am using


    onchange="this. form.ac.value=' delete';this.fo rm.submit()


    Many thanks


  • kaeli

    #2
    Re: Javascript error headache: object doesn't support this property or method

    In article <41179c66@212.6 7.96.135>, michell@colby.n et enlightened us with...[color=blue]
    >
    > This is the URL: http://www.workwise-ely.org/directory/add.php
    >[/color]

    Netscape says:
    this.form.submi t is not a function
    when I change the business category select element.

    I cannot for the life of me find the script that runs with the onchange of
    your form fields to populate the boxes. The error's in there somewhere with
    the scope of the 'this' keyword.

    --
    --
    ~kaeli~
    Why did kamikaze pilots wear helmets?



    Comment

    • Grant Wagner

      #3
      Re: Javascript error headache: object doesn't support this property ormethod

      "news.onetel.ne t.uk" wrote:
      [color=blue]
      > I and my friend Karl have spent literally all day trying to find out what is
      > causing my error but we are zapped of any further functionality :)
      >
      > I have a form that adds news records. You select 'City' then you select
      > 'Business Category' - now when you select 'Business Category' the next
      > drop-down menu (business sub category) should populate with 'Business
      > Sub-categories' related to the 'Business Category' but once 'Business
      > Category' is selected I get the javascript error:
      >
      > Line: 98
      > char: 25
      > error: object doesn't support this property or method
      > code: 0
      >
      > Can anyone save us?
      >
      > This is the URL: http://www.workwise-ely.org/directory/add.php
      >
      > This is the siurce: http://www.workwise-ely.org/directory/form.txt
      >
      > On the 'business_categ ory' I am using
      >
      > onchange="this. form.ac.value=' delete';this.fo rm.submit()
      >
      > Many thanks[/color]

      I see onchange="form. pr.ac.value='pr ';form.pr.submi t()" for the
      business_catego ry, not what you've got listed above.

      Presumably you mean "this.form.pr.a c.value....", but "pr" is not a property of
      the form, it's the id of the form, and "this.form" gives you a reference to that
      form, the id is not required.

      So, to set the value of another input you'd use
      onchange="this. form.ac.value=' whatever';this. form.submit();"

      --
      Grant Wagner <gwagner@agrico reunited.com>
      comp.lang.javas cript FAQ - http://jibbering.com/faq

      Comment

      • Michael Winter

        #4
        Re: Javascript error headache: object doesn't support this property or method

        On Mon, 9 Aug 2004 16:45:33 +0100, news.onetel.net .uk <michell@colby. net>
        wrote:
        [color=blue]
        > I have a form that adds news records. You select 'City' then youselect
        > 'Business Category' - now when you select 'BusinessCatego ry'the next
        > drop-down menu (business sub category) shouldpopulate with'Business
        > Sub-categories' related to the 'BusinessCatego ry' butonce 'Business
        > Category' is selected I get thejavascript error:[/color]

        You shouldn't be doing it with JavaScript if you have server-side support.
        To do so will make your page needlessly dependent upon JavaScript. It's
        also unwise to automatically submit a form when someone changes a value in
        a SELECT element. This is because two methods of changing values, by
        keyboard and by mouse wheel, result in several change events. Furthermore,
        a user can't change their minds or make a correction. Instead they have to
        wait for the server response before they can try again. Lastly, if they
        stop the submission, but then realise that it was the most appropriate
        option, they can't continue because they already have that value selected
        and selecting it again won't fire an event. Instead, they have to select a
        different option before reselecting[1].
        [color=blue]
        > Line: 98
        > char: 25
        > error: object doesn't support this property or method
        > code: 0
        >
        > Can anyone save us?[/color]

        Well you can start by using a different browser for debugging and testing
        documents. IE is a lowsy browser. Be sure to use a better one like Mozilla
        or Opera before deploying a page. Despite being more standard's compliant,
        these browsers offer better script error feedback by default (no updates
        required).

        [snip]
        [color=blue]
        > On the 'business_categ ory' I am using
        >
        > onchange="this. form.ac.value=' delete';this.fo rm.submit()[/color]

        Actually, you're not. The error Opera shows me is:


        Event thread: onchange
        Error:
        name: TypeError
        message: Statement on line 1: Expression evaluated to null or
        undefined and is not convertible to Object: form.pr
        Backtrace:
        In unknown script
        form.pr.ac.valu e = "pr";
        At unknown location
        {event handler trampoline}

        Searching for that code, I find:

        onchange="form. pr.ac.value='pr ';form.pr.submi t()"

        By the way, the more standards-compliant way to reference forms and form
        controls is through the forms and elements collections:

        onchange="this. form.elements['ac'].value='pr';thi s.form.submit() ;"

        But, as I said above, you should drop that whole thing anyway.

        Now we have that sorted, on to other matters...

        Minor points

        I'd change the images (Business and Enterprise, and Investors In People)
        so that they don't shift down when hovered. It looks like something went
        wrong when you altered them.

        At the bottom of the page, it states: "This website is compliant in: XHTML
        | CSS | WAI-AAA". It isn't valid XHTML, and I couldn't check the CSS
        because the mark-up was broken. Don't claim these things if they're
        untrue. Also, it should probably read, "This website complies with the
        following standards: ...".

        Overall, there are seven spelling and grammar mistakes in the "In
        Associating With..." section.

        The name for electronic messages is "e-mail", not "email".

        Technical matters

        I don't know why your script expends so much energy on code to open new
        windows. New windows are a Bad Thing. Don't use them. Pop-up blockers also
        make them unreliable.

        Steer clear of Dreamweaver generated JavaScript code. It's nasty. I'd
        personally recommend steering clear of Dreamweaver, but that may not be an
        option. By the way, I hope nothing ever goes wrong with YY_checkform(). :)

        Please learn to use feature detection. Just because a browser supports
        document.getEle mentById doesn't mean it supports every W3C-specified
        object and method. Similarly, it isn't just IE that provides the
        document.all collection. See the group FAQ, specifically section 4.26 and
        its links. <URL:http://jibbering.com/faq/>

        This goes with the previous point, but it deserves some extra attention.
        Your CSS switcher is a bad idea. Not all browsers support the
        document.styleS heets collection, thereby rendering the entire function
        worthless. Instead, use the intended method of stylesheet switching:
        alternate stylesheets. All good browsers will allow the user to switch the
        active stylesheet using some built-in method. IE, being a terrible
        browser, does not, so your function still serves a purpose in augmenting
        that particular browsers failings. Still, it requires feature detection.

        Mike


        [1] This last case happened to me on another site just 10 minutes ago. So
        yes, these things do occur.

        --
        Michael Winter
        Replace ".invalid" with ".uk" to reply by e-mail

        Comment

        Working...