Determine If Object Exist

Discussion in 'Javascript' started by crjunk, Jul 5, 2005.

  1. crjunk

    crjunk Guest

    I have a script that will set the focus to a particular input box. I
    want the script to check to see if the input box exist also.

    I'm receiving the following error:
    'document.ScheduleForm.txtGrossPayroll99' is null or not an object.

    The txtGrossPayroll99 is a field that does not exist. I've hard-coded
    this name into the script to see if it is working correctly.
    I'm using the OnLoad event inside the <Body> tag to execute this
    function.


    var formInUse = false;
    function setFocus()
    {
    if ((!formInUse) && (typeof(document.ScheduleForm.txtGrossPayroll99) !=
    "undefined") && (typeof(document.ScheduleForm.txtGrossPayroll99) !=
    null) );{
    document.ScheduleForm.txtGrossPayroll99.focus();
    }
    }

    Can someone tell me what I'm doing wrong?

    Thanks,
    CR Junk
     
    crjunk, Jul 5, 2005
    #1
    1. Advertising

  2. crjunk

    BootNic Guest

    > "crjunk" <> wrote:
    > news:....
    >
    > I have a script that will set the focus to a particular input box. I
    > want the script to check to see if the input box exist also.
    >
    > I'm receiving the following error:
    > 'document.ScheduleForm.txtGrossPayroll99' is null or not an object.
    >
    > The txtGrossPayroll99 is a field that does not exist. I've hard-coded
    > this name into the script to see if it is working correctly.
    > I'm using the OnLoad event inside the <Body> tag to execute this
    > function.
    >
    >
    > var formInUse = false;
    > function setFocus()
    > {
    > if ((!formInUse) && (typeof(document.ScheduleForm.txtGrossPayroll99)
    > != "undefined") && (typeof(document.ScheduleForm.txtGrossPayroll99) !=
    > null) );{
    > document.ScheduleForm.txtGrossPayroll99.focus();
    > }
    > }
    >
    > Can someone tell me what I'm doing wrong?
    >
    > Thanks,
    > CR Junk


    /*If ScheduleForm true check for txtGrossPayroll99*/
    if(document.ScheduleForm){
    /*If txtGrossPayroll99 true alert yup*/
    if(document.ScheduleForm.txtGrossPayroll99){alert('yup')}
    /*Esle if txtGrossPayroll99 false alert nope*/
    else if(!document.ScheduleForm.txtGrossPayroll99){alert('nope')}
    }
    /*If SCheduleForm false alert No form to check*/
    else if(!document.ScheduleForm){alert('No form to check')}

    --
    BootNic Tuesday, July 05, 2005 5:57 PM

    I try to take one day at a time, but sometimes several days attack me at once.
    *Jennifer Unlimited*
     
    BootNic, Jul 5, 2005
    #2
    1. Advertising

  3. crjunk

    crjunk Guest

    Thanks for your help. By adding the "if
    (document.ScheduleForm.txtGr­ossPayroll99)" piece of code, my function
    now works correctly.

    CR Junk
     
    crjunk, Jul 6, 2005
    #3
  4. JRS: In article <WnDye.764$>, dated
    Tue, 5 Jul 2005 21:58:14, seen in news:comp.lang.javascript, BootNic
    <> posted :
    >
    >BootNic Tuesday, July 05, 2005 5:57 PM


    In an international medium, giving the time to the minute is rather
    pointless unless you also give the offset from GMT/UTC. Don't use a TLA
    for that; BST has at least three meanings.

    Presumably your offset is in the range -4 to -9 hours, since you give an
    FFF-compatible time.

    --
    © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
    Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
    PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
    Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
     
    Dr John Stockton, Jul 6, 2005
    #4
  5. crjunk

    Randy Webb Guest

    Dr John Stockton wrote:

    > JRS: In article <WnDye.764$>, dated
    > Tue, 5 Jul 2005 21:58:14, seen in news:comp.lang.javascript, BootNic
    > <> posted :
    >
    >>BootNic Tuesday, July 05, 2005 5:57 PM

    >
    >
    > In an international medium, giving the time to the minute is rather
    > pointless unless you also give the offset from GMT/UTC.


    Even then it is pointless, except to people who like to be pedantic
    about the minutes.


    > Don't use a TLA for that; BST has at least three meanings.


    EST probably has more than that......

    > Presumably your offset is in the range -4 to -9 hours, since you give an
    > FFF-compatible time.


    Making assumptions again?

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
     
    Randy Webb, Jul 6, 2005
    #5
  6. JRS: In article <>, dated Wed, 6 Jul
    2005 18:16:22, seen in news:comp.lang.javascript, Randy Webb
    <> posted :
    >Dr John Stockton wrote:


    >> Don't use a TLA for that; BST has at least three meanings.

    >
    >EST probably has more than that......


    Chronologically, only Eastern Standard Time, as far as I know - in
    America and in Australia. Anyone know, for certain, of any others? It
    also has a meaning in Latin and French, at least.


    >> Presumably your offset is in the range -4 to -9 hours, since you give an
    >> FFF-compatible time.

    >
    >Making assumptions again?


    When the context implies nothing about time-of-day, few other than
    Americans would use the 12-hour clock to state the time-of-day in an
    international technical communication medium. The hypothesis is
    supported by his use of prodigy.net, an organisation unwise enough to
    put NNTP-Posting-Date: Tue, 05 Jul 2005 17:58:14 ETD in his header.

    Americans find it hard to understand exactly how silly and parochial the
    rest of the world finds them to be. How much foreign travel (not
    counting in Canada, if any) did your present President do in the Second
    Millennium?

    --
    © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
    Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
    PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
    Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
     
    Dr John Stockton, Jul 7, 2005
    #6
  7. crjunk

    Randy Webb Guest

    Dr John Stockton wrote:

    > JRS: In article <>, dated Wed, 6 Jul
    > 2005 18:16:22, seen in news:comp.lang.javascript, Randy Webb
    > <> posted :
    >
    >>Dr John Stockton wrote:

    >
    >
    >>> Don't use a TLA for that; BST has at least three meanings.

    >>
    >>EST probably has more than that......

    >
    >
    > Chronologically, only Eastern Standard Time, as far as I know - in
    > America and in Australia.


    Just because you don't know doesn't mean they don't exist, hence my use
    of the word "probably", but it's irrelevant.

    > Anyone know, for certain, of any others? It
    > also has a meaning in Latin and French, at least.
    >
    >
    >
    >>>Presumably your offset is in the range -4 to -9 hours, since you give an
    >>>FFF-compatible time.

    >>
    >>Making assumptions again?

    >
    >
    > When the context implies nothing about time-of-day, few other than
    > Americans would use the 12-hour clock to state the time-of-day in an
    > international technical communication medium.


    The context I read what you replied to, which was a signature, was
    indeed a time of day, but you chose to read it the way you wanted to
    read it. That's your choice but it doesn't make you right.


    > The hypothesis is supported by his use of prodigy.net, an organisation
    > unwise enough to put NNTP-Posting-Date: Tue, 05 Jul 2005 17:58:14 ETD
    > in his header.


    The problem with the support of your hypothesis is an incorrect
    assumption. I am sure you can find the incorrect assumption.

    >
    > Americans find it hard to understand exactly how silly and parochial the
    > rest of the world finds them to be.


    And the rest of the world finds it hard to understand why most Americans
    don't care what the rest of the world thinks.


    > How much foreign travel (not counting in Canada, if any) did your present
    > President do in the Second Millennium?


    What this has to do with the date/time stamp in a signature totally
    eludes me, but, I will answer you anyway even though I know it's nothing
    more than an attempt by you to display your blatantly anti-US attitude.

    An exact answer, I do not know and I do not care. An educated guess?
    Probably more times than the Queen Mother depended on the US to save her
    crown in the last 100 years.

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
     
    Randy Webb, Jul 9, 2005
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Y.S.
    Replies:
    3
    Views:
    1,024
    strajan
    Sep 17, 2003
  2. LT
    Replies:
    7
    Views:
    2,099
    Phlip
    Jul 25, 2004
  3. Peña, Botp
    Replies:
    1
    Views:
    241
    Robert Klemme
    Jan 24, 2004
  4. Markus Mohr
    Replies:
    7
    Views:
    250
    Thomas 'PointedEars' Lahn
    Nov 28, 2003
  5. George
    Replies:
    7
    Views:
    160
    Thomas 'PointedEars' Lahn
    Oct 3, 2009
Loading...

Share This Page