Reply
Firefox Javascript Problem
Old 03-15-2006, 04:48 PM Firefox Javascript Problem
efriese's Avatar
Average Talker

Posts: 21
Location: Auburn, AL
Does anyone know why this doesn't work in firefox?

Code:
	  <SCRIPT LANGUAGE="Javascript">
	<!--
	document.forms("form1").submit()
	//--></SCRIPT>
It works fine in IE. I'm trying to automatically submit an HTML form. Does anyone know any alternatives that will work in both IE and Firefox?

Thanks in advance!
__________________
Find E-Commerce Discussions and Resources at E-Commerce Boards
efriese is offline
Reply With Quote
View Public Profile Visit efriese's homepage!
 
When You Register, These Ads Go Away!
Old 03-15-2006, 05:01 PM Re: Firefox Javascript Problem
vangogh's Avatar
Post Impressionist

Posts: 8,825
Name: Steven Bradley
Location: Boulder, Colorado
I think what you want is document.forms["form1"].submit();

Brackets [] around "form1" and not parenthesis ()
__________________
l Search Engine Friendly Web Design | Van SEO Design
l Tips On Marketing, SEO, Design, and Development | TheVanBlog
l Custom WordPress Themes
| Small Business Forum
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 03-15-2006, 05:09 PM Re: Firefox Javascript Problem
chrishirst's Avatar
Super Moderator

Posts: 13,609
Location: Blackpool. UK
document.forms["form1"].submit()
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-15-2006, 05:51 PM Re: Firefox Javascript Problem
efriese's Avatar
Average Talker

Posts: 21
Location: Auburn, AL
I tried changing it, but it still doesn't work in firefox. Any other ideas?
__________________
Find E-Commerce Discussions and Resources at E-Commerce Boards
efriese is offline
Reply With Quote
View Public Profile Visit efriese's homepage!
 
Old 03-15-2006, 11:29 PM Re: Firefox Javascript Problem
vangogh's Avatar
Post Impressionist

Posts: 8,825
Name: Steven Bradley
Location: Boulder, Colorado
Could you post more of the code or a link to the page? Seeing the rest of the code would help in being able to figure out what's going on. Thanks.
__________________
l Search Engine Friendly Web Design | Van SEO Design
l Tips On Marketing, SEO, Design, and Development | TheVanBlog
l Custom WordPress Themes
| Small Business Forum
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 03-16-2006, 08:35 AM Re: Firefox Javascript Problem
efriese's Avatar
Average Talker

Posts: 21
Location: Auburn, AL
Code:
<html>
<form method="post" id="form1" name="form1" action="https://payments.verisign.com/payflowlink">
<input type="hidden" name="LOGIN" value="">
<input type="hidden" name="PARTNER" value="Verisign">
<input type="hidden" name="AMOUNT" value="">
<input type="hidden" name="TYPE" value="S">
</form>
	  <SCRIPT LANGUAGE="Javascript">
	<!--
	document.forms["form1"].submit()
	//--></SCRIPT>
</html>
That's all of the HTML...minus the login information. I can't really give a link to the page yet. Can anyone see a reason why that Javascript code doesn't work with firefox?
__________________
Find E-Commerce Discussions and Resources at E-Commerce Boards
efriese is offline
Reply With Quote
View Public Profile Visit efriese's homepage!
 
Old 03-16-2006, 11:59 AM Re: Firefox Javascript Problem
vangogh's Avatar
Post Impressionist

Posts: 8,825
Name: Steven Bradley
Location: Boulder, Colorado
I'm not seeing anything obvious. You could try using document.form1.submit() and access the form directly instead of going through the forms array to see if that will work.

Usually when I've used code like you have in the javascript I've placed it in the head of the document instead of in the body. Not sure it should make a difference, but easy enough to see if it works that way.

Just curious about why you want this to be automatically submitted. Wouldn't this be the kind of thing you would submit once a visitor to your site has agreed to purchase somethng? Is there a reason why you can't just use a normal submit button?
__________________
l Search Engine Friendly Web Design | Van SEO Design
l Tips On Marketing, SEO, Design, and Development | TheVanBlog
l Custom WordPress Themes
| Small Business Forum
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 03-16-2006, 03:16 PM Re: Firefox Javascript Problem
efriese's Avatar
Average Talker

Posts: 21
Location: Auburn, AL
I tried that...but it still didn't work. The reason why I'm doing that is because I'm sending that data to the payment processor after doing a some actions in PHP before that. I didn't know a better way of sending that data when it has to be sent by a POST action.
__________________
Find E-Commerce Discussions and Resources at E-Commerce Boards
efriese is offline
Reply With Quote
View Public Profile Visit efriese's homepage!
 
Old 03-16-2006, 03:55 PM Re: Firefox Javascript Problem
vangogh's Avatar
Post Impressionist

Posts: 8,825
Name: Steven Bradley
Location: Boulder, Colorado
That makes sense.

It looks to me like your html and javascript are correct. I tried an experiment where I took your code, changed the value for the action and loaded the page locally using Firefox. It seemed to work for me so I'm thinking that it's not this code causing the problem.

What happens when you use Firefox? Does the page go to verisign at all and just not work or does it stay on the page itself?
__________________
l Search Engine Friendly Web Design | Van SEO Design
l Tips On Marketing, SEO, Design, and Development | TheVanBlog
l Custom WordPress Themes
| Small Business Forum
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 03-17-2006, 01:54 AM Re: Firefox Javascript Problem
efriese's Avatar
Average Talker

Posts: 21
Location: Auburn, AL
It doesn't go to Verisign, it just sits there with a blank page. Pretty puzzling...
__________________
Find E-Commerce Discussions and Resources at E-Commerce Boards
efriese is offline
Reply With Quote
View Public Profile Visit efriese's homepage!
 
Old 03-17-2006, 10:26 AM Re: Firefox Javascript Problem
trendybox's Avatar
Experienced Talker

Posts: 43
maybe try a numerical reference to the form instead of calling it by name:

Code:
 
document.forms[0].submit()
__________________
-[Trendy Box]-
http://trendybox.net
trendybox is offline
Reply With Quote
View Public Profile Visit trendybox's homepage!
 
Old 03-17-2006, 12:45 PM Re: Firefox Javascript Problem
vangogh's Avatar
Post Impressionist

Posts: 8,825
Name: Steven Bradley
Location: Boulder, Colorado
That is strange efries. Like I said I copied your code above and just replaced the action of the form to point to another file which I created. When I loaded the page with your code it went right to my second page which is making me think the problem isn't with this code, but something else.

I just tried it again with the form action pointing to verisign and it worked as well. I get a data error page at verisign asking for the login name and the value for the amount.

I'm using Firefox 1.5.0.1

I think the problem is something other than the javascript or the html for the form. Maybe something else on the page is causing the problem. Is there more of the page you could post? I'd be happy to take a look.
__________________
l Search Engine Friendly Web Design | Van SEO Design
l Tips On Marketing, SEO, Design, and Development | TheVanBlog
l Custom WordPress Themes
| Small Business Forum
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 03-17-2006, 03:58 PM Re: Firefox Javascript Problem
Christopher's Avatar
Iced Cap

Latest Blog Post:
PHP and Unicode with UTF-8
Posts: 3,111
Location: Toronto, Ontario
Try just putting

Code:
alert("I got here");
And see if it runs. Or try putting the code into a function, and run it on onload.

In <head>:
Code:
function submitForm()
{
    document.forms["form1"].submit();
}

window.onload = submitForm;
Christopher is offline
Reply With Quote
View Public Profile Visit Christopher's homepage!
 
Old 03-24-2006, 01:04 AM Re: Firefox Javascript Problem
Super Talker

Posts: 144
perhaps because you don't have the BODY tag, and FF can't reference the document?

<html>
<head>
<title>title to page</title>
</head>

<body>

code here

</body>
</html>
__________________
create.vibe
web development portfolio
createvibe.com is offline
Reply With Quote
View Public Profile Visit createvibe.com's homepage!
 
Old 03-25-2006, 12:26 PM Re: Firefox Javascript Problem
ermau's Avatar
Experienced Talker

Latest Blog Post:
Chopper pwnage
Posts: 47
Name: Eric
Location: Florida
Yes, proper HTML might help.
__________________
PHP / mySQL Developer
ermau is offline
Reply With Quote
View Public Profile
 
Old 10-18-2006, 08:49 PM Re: Firefox Javascript Problem
jjt
Junior Talker

Posts: 1
Name: Jacinta
did you find a solution to this?
i am having a similar problem with an asp.net form. works fine in IE but just posts back to the same page in Firefox. Here is the code:

if(typeof(delayPostBack == 'function'))
{

if(navigator.userAgent.indexOf("Firefox") != -1)
{
var theform = document.forms["Form1"];
var eventTarget = "ImageButton";
theform.__EVENTTARGET.value = eventTarget.split("$").join(":"); theform.submit();
}
else
{delayPostBack();}
}
jjt is offline
Reply With Quote
View Public Profile
 
Old 10-19-2006, 01:17 AM Re: Firefox Javascript Problem
seomumbai's Avatar
Skilled Talker

Posts: 98
I think ther insted of [] these u have to give ().
seomumbai is offline
Reply With Quote
View Public Profile
 
Old 01-31-2007, 06:40 PM Re: Firefox Javascript Problem
Junior Talker

Posts: 2
Name: David Joshua Rodman
Well -- rather than struggle with Firefox, if you're in PHP already and need to POST to Verisign, I'd suggest using curl. That way you're doing it all within the PHP program, and you're not in any way dependent on browser capabilities or settings. Here's a fairly general function you can use:
/**
* grab a page from the given site, posting the given fields
* if no fields, no POST, just get the page.
*/
function grab_page($site, $fields = '')
{ $cfd = curl_init();
$qstring = '';
if(is_array($fields))
{ $first = true;
$qstring = '';
foreach($fields as $K => $V)
{ if($first)
$first = false;
else
$qstring .= '&';
$qstring .= "$K=$V";
}
}

curl_setopt($cfd, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($cfd, CURLOPT_URL, $site);
curl_setopt($cfd, CURLOPT_RETURNTRANSFER, 1);
if(!empty($qstring))
{ curl_setopt($cfd, CURLOPT_POST, 1);
curl_setopt($cfd, CURLOPT_POSTFIELDS, $qstring);
}