By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,839 Members | 2,270 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,839 IT Pros & Developers. It's quick & easy.

Multiple Form Post Using Javascript - Empty Post from FF

P: n/a
Hey,

I'm using JS to submit a form with image submit buttons, using the
following code...

(Page is here... http://www.cards2do.co.uk/addcard.php?card_id=292 )

************************************************** ************************************

<form action="https://www.cards2do.co.uk/addcard.php" method="post"
id="loginform">
Username:

..................... Rest of Form.....................

<input type="hidden" name="submit" value="true"/>
<input type="image" src="images/buttons/login.gif" alt="Click To Login"
onclick="javascript:document.loginform.submit();"/>
</form>

************************************************** ************************************

There are two forms on this particular page... They use identical code
except that the second form has a different name (also updated in the
onclick event), and the dummy submit variable has a different name to
help the PHP.

The problem...
Everything works perfectly in IE... both the user login and the "adding
card" form work great.
However in Firefox... the login works perfectly but the "adding card"
form does not. Using the PHP function "var_dump($_POST)" hsa shown me
that the post from firefox is a totally null array. No keys or values
are present at all. Firefox reported no Javascript errors in the
console when I ran it.

I would be extremely grateful if anyone knows the cause of the problem.
I would assume it's my Javascript rather than Firefox! : )

Many Thanks,

Adam King
Cards2do.co.uk

Nov 23 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
vdP
Adam wrote:
Hey,

I'm using JS to submit a form with image submit buttons, using the
following code...

(Page is here... http://www.cards2do.co.uk/addcard.php?card_id=292 )

************************************************** ************************************

<form action="https://www.cards2do.co.uk/addcard.php" method="post"
id="loginform">
Username:

.................... Rest of Form.....................

<input type="hidden" name="submit" value="true"/>
<input type="image" src="images/buttons/login.gif" alt="Click To Login"
onclick="javascript:document.loginform.submit();"/>
</form>

************************************************** ************************************
The problem...
Everything works perfectly in IE... both the user login and the "adding
card" form work great.
However in Firefox... the login works perfectly but the "adding card"
form does not. Using the PHP function "var_dump($_POST)" hsa shown me
that the post from firefox is a totally null array. No keys or values
are present at all. Firefox reported no Javascript errors in the
console when I ran it.


Surprisingly, my Firefox showed the following error after submitting the
form.

Error: document.loginform has no properties
Source File: https://www.cards2do.co.uk/addcard.php
Line: 1

To solve the problem replace the onclick attribute in the submit image
to onclick="javascript:document.getElementByID('login form').submit();" .
That should work in Firefox and IE.

vdP
Nov 23 '05 #2

P: n/a
Brilliant... Thanks for your help guys, I will try out your suggestions
tomorrow and let you know!

Cheers,
Adam

Nov 23 '05 #3

P: n/a
Hey,

I tried out both your suggestions but still no luck! Firefox still
sends empty posts for only the "add card" form on the page. It says
that document.getElementByID is not a function.. (I tried different
capitalisations of the function name just in case)

Do you guys have any other thoughts?

Cheers for your help so far!
Adam

Nov 23 '05 #4

P: n/a
Adam wrote:
I tried out both your suggestions but still no luck! Firefox still
sends empty posts for only the "add card" form on the page. It says
that document.getElementByID is not a function.. (I tried different
capitalisations of the function name just in case)


You did not try `document.getElementById'. And

<input type="image" ...
onclick="javascript:document.getElementbyId('infof orm').submit();"/>

is nonsense.

1. `javascript:' is nonsensical where supported as designed
(to generate an HTML document from script code; the submit()
method returns `undefined') and error-prone when not supported.
Omit that and add

<meta http-equiv="Content-Script-Type" content="text/javascript" />

to the `head' element.

2. The `input' element is descendant of the `form' element referred to.
If it were not already a submit control, that form element could be
easily referred to by `this.form'. No need for getElementById()
and the like.

3. input[type="image"] are submit controls, there is no need for scripting.

4. <http://hixie.ch/advocacy/xhtml>
HTH

PointedEars
Nov 23 '05 #5

P: n/a
Thanks Thomas...

I implemented the code vdP recommended to the letter. That was the
output Firefox gave in the console.

I tried removing the "onclick" attribute all together...
Unfortunately... still the same problem! IE is happy with the login and
the "addcard" form, but Firefox only posts the login form.

Your point number 4... I had a browse through that page, are you saying
you think the problem was due to the pages being served as text/html
MIME type? (or something along those lines?)

So with the page now using no JS to submit the forms, the problems
remain! : (

I'm still totally clueless about this one... any more ideas? : )

Thanks,
Adam

Nov 23 '05 #6

P: n/a
Adam wrote:
I implemented the code vdP recommended to the letter. That was the
output Firefox gave in the console.
"That"? <URL:http://www.jibbering.com/faq/faq_notes/pots1.html>
I tried removing the "onclick" attribute all together...
Unfortunately... still the same problem! IE is happy with the login and
the "addcard" form, but Firefox only posts the login form.
Clear your cache, then try again. If it still does not work, and there is
no JS code whatsoever left, most certainly you do not have a JS problem.
Your point number 4... I had a browse through that page, are you saying
you think the problem was due to the pages being served as text/html
MIME type? (or something along those lines?)
Possibly.
So with the page now using no JS to submit the forms, the problems
remain! : (
Maybe you are assigning an event listener somewhere else or a buggy
extension interferes.
I'm still totally clueless about this one... any more ideas? : )


Not without more/the entire source code, preferably provided through a URL.
PointedEars
Nov 23 '05 #7

P: n/a
On 2005-11-21, Adam <bu**************@gmail.com> wrote:
The problem...
Everything works perfectly in IE... both the user login and the "adding
card" form work great.
However in Firefox... the login works perfectly but the "adding card"
form does not. Using the PHP function "var_dump($_POST)" hsa shown me
that the post from firefox is a totally null array. No keys or values
are present at all. Firefox reported no Javascript errors in the
console when I ran it.


There's probably something wrong with the HTML.

http://validator.w3.org/check?uri=ht...Fcard_id%3D292

claims there are 12 somethings.
--

Bye.
Jasen
Nov 24 '05 #8

P: n/a
Thank you Jasen!

It was an xhtml error... (missed a closing tag). Guess IE blindly
ignored it, while Firefox was (rightly) getting confused. So it's all
working now. I'll use the validator more in future!
Thanks for your help...
Adam

Nov 24 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.