null or not object problem

Discussion in 'Javascript' started by exxos, Feb 17, 2005.

  1. exxos

    exxos Guest

    HI all,


    This has had me confuzzeled for a while now, I've read countless threads on
    such errors and it seems to be down to the way things are set out and
    loaded. Can anyone suggest why this code throws up the null or not object
    error ? The crazy thing is it all actually works fine aswell.....


    <script language='JavaScript'>
    function includeemail()
    {
    var f0 = document.PaypalForm0;
    f0.business.value = "999999"
    </script>
    </head>
    <tr>
    <TD>
    <form name='PaypalForm0'
    action='https://www.paypal.com/cgi-bin/webscr' method='post'
    onsubmit='includeemail()' target='paypal'>
    <input type='image'
    src='https://www.paypal.com/en_GB/i/btn/x-click-but22.gif' border='0'
    name='submit' alt='Make payments with PayPal '>
    <input type='hidden' name='add' value='1'>
    <input type='hidden' name='cmd' value='_cart'>
    <input type='hidden' name='item_name' value='ITEM'>
    <input type='hidden' name='amount' value='VALUE'>
    <input type='hidden' name='no_note' value='1'>
    <input type='hidden' name='currency_code' value='GBP'>
    </form>
    </TD>
    </tr>



    ive cut out the html header stuff etc to make it easier to read..... anyone
    got anyideas ?

    thanks,
    Chris
    exxos, Feb 17, 2005
    #1
    1. Advertising

  2. exxos

    Lee Guest

    exxos said:
    >
    >HI all,
    >
    >
    >This has had me confuzzeled for a while now, I've read countless threads on
    >such errors and it seems to be down to the way things are set out and
    >loaded. Can anyone suggest why this code throws up the null or not object
    >error ? The crazy thing is it all actually works fine aswell.....
    >
    >
    ><script language='JavaScript'>
    >function includeemail()
    >{
    >var f0 = document.PaypalForm0;
    >f0.business.value = "999999"
    ></script>
    ></head>
    ><tr>
    ><TD>
    > <form name='PaypalForm0'
    >action='https://www.paypal.com/cgi-bin/webscr' method='post'
    >onsubmit='includeemail()' target='paypal'>
    > <input type='image'
    >src='https://www.paypal.com/en_GB/i/btn/x-click-but22.gif' border='0'
    >name='submit' alt='Make payments with PayPal '>
    > <input type='hidden' name='add' value='1'>
    > <input type='hidden' name='cmd' value='_cart'>
    > <input type='hidden' name='item_name' value='ITEM'>
    > <input type='hidden' name='amount' value='VALUE'>
    > <input type='hidden' name='no_note' value='1'>
    > <input type='hidden' name='currency_code' value='GBP'>
    > </form>
    ></TD>
    > </tr>
    >
    >
    >
    >ive cut out the html header stuff etc to make it easier to read..... anyone
    >got anyideas ?


    You're referring to the "value" attribute of a form element named
    "business", but there is no such form element. Add another hidden
    field with that name.
    Lee, Feb 17, 2005
    #2
    1. Advertising

  3. exxos

    exxos Guest

    "Lee" <> wrote in message
    news:...
    > exxos said:
    >>
    >>HI all,
    >>
    >>
    >>This has had me confuzzeled for a while now, I've read countless threads
    >>on
    >>such errors and it seems to be down to the way things are set out and
    >>loaded. Can anyone suggest why this code throws up the null or not object
    >>error ? The crazy thing is it all actually works fine aswell.....
    >>
    >>
    >><script language='JavaScript'>
    >>function includeemail()
    >>{
    >>var f0 = document.PaypalForm0;
    >>f0.business.value = "999999"
    >></script>
    >></head>
    >><tr>
    >><TD>
    >> <form name='PaypalForm0'
    >>action='https://www.paypal.com/cgi-bin/webscr' method='post'
    >>onsubmit='includeemail()' target='paypal'>
    >> <input type='image'
    >>src='https://www.paypal.com/en_GB/i/btn/x-click-but22.gif' border='0'
    >>name='submit' alt='Make payments with PayPal '>
    >> <input type='hidden' name='add' value='1'>
    >> <input type='hidden' name='cmd' value='_cart'>
    >> <input type='hidden' name='item_name' value='ITEM'>
    >> <input type='hidden' name='amount' value='VALUE'>
    >> <input type='hidden' name='no_note' value='1'>
    >> <input type='hidden' name='currency_code' value='GBP'>
    >> </form>
    >></TD>
    >> </tr>
    >>
    >>
    >>
    >>ive cut out the html header stuff etc to make it easier to read.....
    >>anyone
    >>got anyideas ?

    >
    > You're referring to the "value" attribute of a form element named
    > "business", but there is no such form element. Add another hidden
    > field with that name.



    makes sence, I did that that but I took it out, it just said the same with
    it in so didn't see the use in it.... I can't set a value for it cos it will
    override the script (I think) setting it to null dont seem to work either ?!

    Chris


    >
    exxos, Feb 17, 2005
    #3
  4. exxos

    Lee Guest

    exxos said:
    >
    >
    >"Lee" <> wrote in message
    >news:...
    >> exxos said:
    >>>
    >>>HI all,
    >>>
    >>>
    >>>This has had me confuzzeled for a while now, I've read countless threads
    >>>on
    >>>such errors and it seems to be down to the way things are set out and
    >>>loaded. Can anyone suggest why this code throws up the null or not object
    >>>error ? The crazy thing is it all actually works fine aswell.....
    >>>
    >>>
    >>><script language='JavaScript'>
    >>>function includeemail()
    >>>{
    >>>var f0 = document.PaypalForm0;
    >>>f0.business.value = "999999"
    >>></script>
    >>></head>
    >>><tr>
    >>><TD>
    >>> <form name='PaypalForm0'
    >>>action='https://www.paypal.com/cgi-bin/webscr' method='post'
    >>>onsubmit='includeemail()' target='paypal'>
    >>> <input type='image'
    >>>src='https://www.paypal.com/en_GB/i/btn/x-click-but22.gif' border='0'
    >>>name='submit' alt='Make payments with PayPal '>
    >>> <input type='hidden' name='add' value='1'>
    >>> <input type='hidden' name='cmd' value='_cart'>
    >>> <input type='hidden' name='item_name' value='ITEM'>
    >>> <input type='hidden' name='amount' value='VALUE'>
    >>> <input type='hidden' name='no_note' value='1'>
    >>> <input type='hidden' name='currency_code' value='GBP'>
    >>> </form>
    >>></TD>
    >>> </tr>
    >>>
    >>>
    >>>
    >>>ive cut out the html header stuff etc to make it easier to read.....
    >>>anyone
    >>>got anyideas ?

    >>
    >> You're referring to the "value" attribute of a form element named
    >> "business", but there is no such form element. Add another hidden
    >> field with that name.

    >
    >
    >makes sence, I did that that but I took it out, it just said the same with
    >it in so didn't see the use in it.... I can't set a value for it cos it will
    >override the script (I think) setting it to null dont seem to work either ?!


    It would complain if you tried to set it in script before
    the form existed, but since you're calling it on submission,
    it will only complain if the field doesn't exist.

    The script doesn't run until you submit, so the script will
    override whatever value you put there. Of course, if you're
    always using the same value, you don't need the script at all.

    By the way, this doesn't contribute to your problem, but:
    <script language='JavaScript'>
    is out-dated. You should be using:
    <script type="text/javascript">
    Lee, Feb 17, 2005
    #4
  5. exxos

    exxos Guest

    "Lee" <> wrote in message
    news:...
    > exxos said:
    >>
    >>
    >>"Lee" <> wrote in message
    >>news:...
    >>> exxos said:
    >>>>
    >>>>HI all,
    >>>>
    >>>>
    >>>>This has had me confuzzeled for a while now, I've read countless threads
    >>>>on
    >>>>such errors and it seems to be down to the way things are set out and
    >>>>loaded. Can anyone suggest why this code throws up the null or not
    >>>>object
    >>>>error ? The crazy thing is it all actually works fine aswell.....
    >>>>
    >>>>
    >>>><script language='JavaScript'>
    >>>>function includeemail()
    >>>>{
    >>>>var f0 = document.PaypalForm0;
    >>>>f0.business.value = "999999"
    >>>></script>
    >>>></head>
    >>>><tr>
    >>>><TD>
    >>>> <form name='PaypalForm0'
    >>>>action='https://www.paypal.com/cgi-bin/webscr' method='post'
    >>>>onsubmit='includeemail()' target='paypal'>
    >>>> <input type='image'
    >>>>src='https://www.paypal.com/en_GB/i/btn/x-click-but22.gif' border='0'
    >>>>name='submit' alt='Make payments with PayPal '>
    >>>> <input type='hidden' name='add' value='1'>
    >>>> <input type='hidden' name='cmd' value='_cart'>
    >>>> <input type='hidden' name='item_name' value='ITEM'>
    >>>> <input type='hidden' name='amount' value='VALUE'>
    >>>> <input type='hidden' name='no_note' value='1'>
    >>>> <input type='hidden' name='currency_code' value='GBP'>
    >>>> </form>
    >>>></TD>
    >>>> </tr>
    >>>>
    >>>>
    >>>>
    >>>>ive cut out the html header stuff etc to make it easier to read.....
    >>>>anyone
    >>>>got anyideas ?
    >>>
    >>> You're referring to the "value" attribute of a form element named
    >>> "business", but there is no such form element. Add another hidden
    >>> field with that name.

    >>
    >>
    >>makes sence, I did that that but I took it out, it just said the same with
    >>it in so didn't see the use in it.... I can't set a value for it cos it
    >>will
    >>override the script (I think) setting it to null dont seem to work either
    >>?!

    >
    > It would complain if you tried to set it in script before
    > the form existed, but since you're calling it on submission,
    > it will only complain if the field doesn't exist.
    >
    > The script doesn't run until you submit, so the script will
    > override whatever value you put there. Of course, if you're
    > always using the same value, you don't need the script at all.


    I'm using the script to hide my E-mail address, its split up into a lot of
    variables, that value is then the same for each form.. but of course I dont
    want to add my full address into the form!

    >
    > By the way, this doesn't contribute to your problem, but:
    > <script language='JavaScript'>
    > is out-dated. You should be using:
    > <script type="text/javascript">


    thanks for the update, I've only been programming in java/asp for the last
    for days, never needed any scripting or anything until recently..

    chris



    >
    exxos, Feb 17, 2005
    #5
  6. exxos

    exxos Guest

    "Lee" <> wrote in message
    news:...
    > exxos said:
    >>
    >>
    >>"Lee" <> wrote in message
    >>news:...
    >>> exxos said:
    >>>>
    >>>>HI all,
    >>>>
    >>>>
    >>>>This has had me confuzzeled for a while now, I've read countless threads
    >>>>on
    >>>>such errors and it seems to be down to the way things are set out and
    >>>>loaded. Can anyone suggest why this code throws up the null or not
    >>>>object
    >>>>error ? The crazy thing is it all actually works fine aswell.....
    >>>>
    >>>>
    >>>><script language='JavaScript'>
    >>>>function includeemail()
    >>>>{
    >>>>var f0 = document.PaypalForm0;
    >>>>f0.business.value = "999999"
    >>>></script>
    >>>></head>
    >>>><tr>
    >>>><TD>
    >>>> <form name='PaypalForm0'
    >>>>action='https://www.paypal.com/cgi-bin/webscr' method='post'
    >>>>onsubmit='includeemail()' target='paypal'>
    >>>> <input type='image'
    >>>>src='https://www.paypal.com/en_GB/i/btn/x-click-but22.gif' border='0'
    >>>>name='submit' alt='Make payments with PayPal '>
    >>>> <input type='hidden' name='add' value='1'>
    >>>> <input type='hidden' name='cmd' value='_cart'>
    >>>> <input type='hidden' name='item_name' value='ITEM'>
    >>>> <input type='hidden' name='amount' value='VALUE'>
    >>>> <input type='hidden' name='no_note' value='1'>
    >>>> <input type='hidden' name='currency_code' value='GBP'>
    >>>> </form>
    >>>></TD>
    >>>> </tr>
    >>>>
    >>>>
    >>>>
    >>>>ive cut out the html header stuff etc to make it easier to read.....
    >>>>anyone
    >>>>got anyideas ?
    >>>
    >>> You're referring to the "value" attribute of a form element named
    >>> "business", but there is no such form element. Add another hidden
    >>> field with that name.

    >>
    >>



    I tried re-adding the element in the form element, but still same problem
    :-( I thought I had tried it before and it didnt work , im out of ideas!
    seems to work fine copied direct into HTML pages though which is odd :-\

    chris
    exxos, Feb 20, 2005
    #6
  7. exxos

    Lee Guest

    exxos said:

    >I tried re-adding the element in the form element, but still same problem
    >:-( I thought I had tried it before and it didnt work , im out of ideas!
    >seems to work fine copied direct into HTML pages though which is odd :-\


    Here's an example that works.
    You can tell that it works because after pressing Submit, the values of the form
    fields are added to the URL (because no ACTION is specified). The only
    significant difference between my code and yours should be the fact that I pass
    a reference to the form into the function, rather than using the full reference
    to it within the function. That eliminates the possibility that you're not
    refering to the form correctly.

    <html>
    <head>
    <script type="text/javascript">
    function includeemail(f) {
    f.business.value = "999999";
    }
    </script>
    </head>
    <body>
    <form name="PayPalForm0" onsubmit="includeemail(this)">
    <input name="demo1" value="apple">
    <input name="business" type="hidden">
    <br>
    <input type="submit" value="Submit">
    </form>
    </body>
    </html>
    Lee, Feb 20, 2005
    #7
  8. exxos

    exxos Guest

    "Lee" <> wrote in message
    news:...
    > exxos said:
    >
    >>I tried re-adding the element in the form element, but still same problem
    >>:-( I thought I had tried it before and it didnt work , im out of
    >>ideas!
    >>seems to work fine copied direct into HTML pages though which is odd :-\

    >
    > Here's an example that works.
    > You can tell that it works because after pressing Submit, the values of
    > the form
    > fields are added to the URL (because no ACTION is specified). The only
    > significant difference between my code and yours should be the fact that I
    > pass
    > a reference to the form into the function, rather than using the full
    > reference
    > to it within the function. That eliminates the possibility that you're
    > not
    > refering to the form correctly.
    >
    > <html>
    > <head>
    > <script type="text/javascript">
    > function includeemail(f) {
    > f.business.value = "999999";
    > }
    > </script>
    > </head>
    > <body>
    > <form name="PayPalForm0" onsubmit="includeemail(this)">
    > <input name="demo1" value="apple">
    > <input name="business" type="hidden">
    > <br>
    > <input type="submit" value="Submit">
    > </form>
    > </body>
    > </html>
    >




    I see that works, passing info to URL works in my own code also. Though ive
    been trying and either the value goes missing or I get the null object
    error......
    why have you got "this" in the includeemail(this)" ? I have a lot of forms,
    so should I be using seperate formanames or the same one ? I also notice you
    haven't got the document line in which I had in my code, I take it thats not
    needed also ?

    all the code was supposed to do is replace my E-mail address (the 99999 bit)
    in the form value business, rather than having my full addy visable to web
    bots, maybe you can suggest a esaier way to do this ? maybe one I can
    understand! :-\

    Chris
    exxos, Feb 20, 2005
    #8
    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. Replies:
    16
    Views:
    7,270
    Mike Schilling
    Oct 12, 2005
  2. Replies:
    5
    Views:
    26,423
    Mike Schilling
    Mar 29, 2006
  3. Cirene
    Replies:
    1
    Views:
    789
    Alexey Smirnov
    Jun 9, 2008
  4. putty
    Replies:
    1
    Views:
    241
    putty
    Apr 5, 2005
  5. Tim Platt

    XMLHTTP - null is null or not an object

    Tim Platt, Jun 4, 2007, in forum: Javascript
    Replies:
    0
    Views:
    167
    Tim Platt
    Jun 4, 2007
Loading...

Share This Page