null or not object problem

E

exxos

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
 
L

Lee

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

exxos

Lee said:
exxos said:

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
 
L

Lee

exxos said:
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">
 
E

exxos

Lee said:
exxos said:

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
 
E

exxos

Lee said:
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 :-\

chris
 
L

Lee

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>
 
E

exxos

Lee said:
exxos said:


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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top