Digital Point Forums
Money Order

Go Back   Digital Point Forums > Design & Development > Programming > JavaScript
Google Analytics
Log In to view
your analytics

Reply
 
Thread Tools
  #1  
Old Nov 16th 2004, 6:20 am
Weirfire's Avatar
Weirfire Weirfire is offline
Web Developer & Marketer
 
Join Date: Jun 2004
Location: Northern Ireland but I'm Scottish
Posts: 6,915
Weirfire has much to be proud ofWeirfire has much to be proud ofWeirfire has much to be proud ofWeirfire has much to be proud ofWeirfire has much to be proud ofWeirfire has much to be proud ofWeirfire has much to be proud ofWeirfire has much to be proud ofWeirfire has much to be proud of
onload error

When you use the document.<formname>.submit function I get an error that states

document.<formname> is null or not an object



Anyone got any ideas how to get rid of this error? I'm expecting expat to know this 1
__________________
Certified Native Translations and EMedia Services - PM me if you are interested?
Web Services
Reply With Quote
  #2  
Old Nov 16th 2004, 8:11 am
expat expat is offline
Stranger from a far land
 
Join Date: Mar 2004
Location: Galicia Spain
Posts: 872
expat is on a distinguished road
Quote:
Originally Posted by Weirfire
....Anyone got any ideas how to get rid of this error? I'm expecting expat to know this 1
well we aim to please.....

if it's regarding the bit of script I think you reffer to....

onload <formname> object MUST exist the object is the actual form name used!

.. echo"onLoad='document.SecureForm.submit();'";
(watch the quotes and semikolons)

...echo "<form target=\"_self\" action=\"https://www.paypal.com/cgi-bin/webscr\" name=\"SecureForm\" method=\"post\">";

M
Reply With Quote
  #3  
Old Nov 16th 2004, 11:28 am
Weirfire's Avatar
Weirfire Weirfire is offline
Web Developer & Marketer
 
Join Date: Jun 2004
Location: Northern Ireland but I'm Scottish
Posts: 6,915
Weirfire has much to be proud ofWeirfire has much to be proud ofWeirfire has much to be proud ofWeirfire has much to be proud ofWeirfire has much to be proud ofWeirfire has much to be proud ofWeirfire has much to be proud ofWeirfire has much to be proud ofWeirfire has much to be proud of
I have the form inside an IF clause which I think why it's causing the error because when it isn't being called it doesnt exist.

hmmm.. I'll have to to think through the pseudocode
__________________
Certified Native Translations and EMedia Services - PM me if you are interested?
Web Services
Reply With Quote
  #4  
Old Nov 16th 2004, 2:13 pm
expat expat is offline
Stranger from a far land
 
Join Date: Mar 2004
Location: Galicia Spain
Posts: 872
expat is on a distinguished road
Quote:
Originally Posted by Weirfire
I have the form inside an IF clause which I think why it's causing the error because when it isn't being called it doesnt exist.

hmmm.. I'll have to to think through the pseudocode
just generate and else that runs the form to a standard out

eg
if gatway pp
form with pp details
else
form to print or so (action print.php)
end
Reply With Quote
  #5  
Old Jan 18th 2005, 1:31 am
phrozen_ra phrozen_ra is offline
Champion of the Naaru
 
Join Date: Jan 2005
Posts: 147
phrozen_ra is an unknown quantity at this point
use this:

instead
Code:
document.<formname>
use
Code:
document.getElementById('<formname>')
__________________
Funny Quotations | Reading Glasses |
Reply With Quote
  #6  
Old Jan 18th 2005, 5:54 am
J.D. J.D. is offline
of the Nightfall
 
Join Date: Nov 2004
Posts: 1,198
J.D. has a spectacular aura aboutJ.D. has a spectacular aura about
Quote:
Originally Posted by phrozen_ra
use this:

instead
document.<formname>

use
document.getElementById('<formname>')
Using getElementById with form name will only work in IE. If you want this to work in all browsers use form ID. If you want to use form name, you should use getElementsByName (this method returns a node list):

Code:
document.getElementById("formid");
document.getElementsByName("formname").item(0);
J.D.

Last edited by J.D.; Jan 18th 2005 at 6:01 am.
Reply With Quote
  #7  
Old Jan 18th 2005, 6:23 am
phrozen_ra phrozen_ra is offline
Champion of the Naaru
 
Join Date: Jan 2005
Posts: 147
phrozen_ra is an unknown quantity at this point
Quote:
Originally Posted by J.D.
Using getElementById with form name will only work in IE.
J.D.
False, also works in Fireforx, Netscape, Opera...

show me one browser used by more than 5% of the total users over the internet, which does not work well with getElementById
__________________
Funny Quotations | Reading Glasses |
Reply With Quote
  #8  
Old Jan 18th 2005, 6:27 am
J.D. J.D. is offline
of the Nightfall
 
Join Date: Nov 2004
Posts: 1,198
J.D. has a spectacular aura aboutJ.D. has a spectacular aura about
Quote:
Originally Posted by phrozen_ra
False, also works in Fireforx, Netscape, Opera...

show me one browser used by more than 5% of the total users over the internet, which does not work well with getElementById
No it doesn't. Try this in IE and FF:

Code:
<html>
<head>
<script type="text/javascript">
function myonclick(input)
{
	alert(document.getElementById("formid").nodeName);
	alert(document.getElementById("formname").nodeName);
	alert(document.getElementsByName("formname").item(0).nodeName);
}
</script>
</head>
<body>
<form id="formid" name="formname" action="formid.html">
<input type="button" onclick="myonclick(this)" value="Click!">
</form>
</body>
</html>
ID and name are not interchangeable. There may be only one element with a given ID and there may be more than one with a given name.

J.D.
Reply With Quote
  #9  
Old Jan 18th 2005, 7:58 am
phrozen_ra phrozen_ra is offline
Champion of the Naaru
 
Join Date: Jan 2005
Posts: 147
phrozen_ra is an unknown quantity at this point
it won't logicaly work.... and the bug is here:
alert(document.getElementById("formname").nodeName);

you don't have an id="formname" there.... why do you try to use it?

it works only in IE, because IE is tought that way.... but logicaly you are calling a unknown element by an unexistent ID...

It is somehow my bad cause I forgot to mention that <formname> must be be passed to id also...

Quote:
There may be only one element with a given ID and there may be more than one with a given name.
and what's bad in having distinct IDs?
__________________
Funny Quotations | Reading Glasses |
Reply With Quote
  #10  
Old Jan 18th 2005, 7:59 am
phrozen_ra phrozen_ra is offline
Champion of the Naaru
 
Join Date: Jan 2005
Posts: 147
phrozen_ra is an unknown quantity at this point
furthermore if you would use CSS... you'd notice that distinct IDs help a lot
__________________
Funny Quotations | Reading Glasses |
Reply With Quote
  #11  
Old Jan 18th 2005, 8:18 am
J.D. J.D. is offline
of the Nightfall
 
Join Date: Nov 2004
Posts: 1,198
J.D. has a spectacular aura aboutJ.D. has a spectacular aura about
Quote:
Originally Posted by phrozen_ra
it won't logicaly work.... and the bug is here:
alert(document.getElementById("formname").nodeName);

you don't have an id="formname" there.... why do you try to use it?

it works only in IE, because IE is tought that way.... but logicaly you are calling a unknown element by an unexistent ID...

It is somehow my bad cause I forgot to mention that <formname> must be be passed to id also...



and what's bad in having distinct IDs?
Man, it's like you are reading between the lines. The rule is simple - use getElementById only with IDs and use getElementsByName with names, whatever they are. That's it. You quoted in your initial example getElementById used with the form name, which was incorrect. Even if your ID and name are the same, you should've used ID to avoid ambiguity.

J.D.
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CC Authorize error code smonahan Optigold ISP 19 Mar 21st 2006 4:52 pm
Parse Error vintageagain Co-op Advertising Network 6 Nov 7th 2004 2:28 pm
Call to undefined function error Patient Co-op Advertising Network 2 Nov 2nd 2004 6:08 am
LinkSwapper programming error Shine Programming 1 Aug 26th 2004 7:10 pm
Web Access Error craig Optigold ISP 8 Jun 30th 2004 2:51 pm


All times are GMT -8. The time now is 1:51 am.