Submit form disappears on second call


I seem to be having a strange problem. I have a form_remote_tag which i
submit using a javascript call:

if(document.forms[‘myform’].onsubmit()) {
document.forms[‘myform’].submit(); }

This works great the first time the call is made - however the second
time it doesn’t seem to work - the form seems to have disappeared and
have no properties. I then need to refresh the page and it work again,
then doesn’t work on the second attempt, again…

Any ideas?

Do i have to reload the page after using ajax to submit a form, in order
to re-use the form?

Thanks for your time

James, sounds like you’re your :update is writing over your form

look at the partial you’re rendering, and the contents, and what div
your rendering too - likely you’re rendering to an ID outside the
form_tag, with a partial that doesn’t contain the form_tag.


On Feb 24, 7:43 am, James S. [email protected]

James - on second thought it might be the opposite ( you’re rendering
the form_tag twice )

but your best bet, sort of a teach a man to fish, is to pickup
[1]firebug - you’ll sleep better.


Hey James - I suggest that it’s the first submit that’s causing the
problem (symptom) you’re seeing, when you try to submit it the second

Follow the logic carefully
#1. what is the ID that your form result is rendering to? (:update
=> ‘id’)
#2. what partial is being rendered by your controller? What is
inside this partial?
#3. what is currently inside that ID? (on the first render)

I suggest that one of 2 things is happening:
A. the partial being rendered by the controller (in #2) is rendering
a second form - if this form is inside the current form, or has the
same ID then the Second Form Submit will fail to work
B. the partial being rendered is not rendering the Form Tag - and so
when you click to submit, the form cannot be found.

this will take some investigation on your part. But if you are careful
you should be able to find out the confusion - and learn a valuable
lesson on the way.

On Feb 24, 5:35 pm, James S. [email protected]

but your best bet, sort of a teach a man to fish, is to pickup
[1]firebug - you’ll sleep better.


Thanks for this, this seems like a great tool.

When i submit the form on the second time i am getting errors in the
The first error is as follows:

this.element has no properties
(no name)(undefined)prototype.js (line 265)
_each(function())prototype.js (line 456)
each(function())prototype.js (line 261)
collect(function())prototype.js (line 293)
invoke(“loop”)prototype.js (line 349)
loop()effects.js (line 239)
bind()prototype.js (line 48)
[Break on this error] if(this.element.getStyle(‘display’)==‘none’) {
this.cancel(); return; }

and then the console is repeatedly throwing the following error:

this.element has no properties
[Break on this error] this.element.setStyle({backgroundColor:

and so it keeps going repeatedly throwing the latter error…

So from this i gather that it cannot find the form element… but then
i’m not sure how i can read further into this and solve my problem, any

Finally, i have discovered my wrongs…

I was using effects.js in my rjs file to highlight the form after it had
been submitted, and this was causing the form to effectively disappear.

Why it took me so long to figure out i will never know…

Thanks for your help on this, firebug is a great tool.