first form is ignored, second form is forms[0] why?

G

groups2

Does anyone recognize this situation and know what causes it ?

The page starts with just a search form. When you do a search the page
now has a search results form, a save botton, and the search form at
the bottom. There is also a link to add another form with a
dropdown. If you add the third form the page has the search results
form, the form with the dropdown and the search form, in that order.

The save button is set to submit the search results, which is always
forms[0]. If the page has all 3 forms, it works fine. The first form
is submitted,and it is the correct form. If however, the page only has
2 forms, the search results form is ignored, and the form submitted as
forms[0] is the second form, the search form.

document.forms.length is 2 so there does indeed seem to be 2 forms.
What happened to the first form ? Why is it being ignored.
 
R

Rik

Does anyone recognize this situation and know what causes it ?

The page starts with just a search form. When you do a search the page
now has a search results form, a save botton, and the search form at
the bottom. There is also a link to add another form with a
dropdown. If you add the third form the page has the search results
form, the form with the dropdown and the search form, in that order.

The save button is set to submit the search results, which is always
forms[0]. If the page has all 3 forms, it works fine. The first form
is submitted,and it is the correct form. If however, the page only has
2 forms, the search results form is ignored, and the form submitted as
forms[0] is the second form, the search form.

document.forms.length is 2 so there does indeed seem to be 2 forms.
What happened to the first form ? Why is it being ignored.

Source/URL?
 
G

groups2

Does anyone recognize this situation and know what causes it ?
The page starts with just a search form. When you do a search the page
now has a search results form, a save botton, and the search form at
the bottom. There is also a link to add another form with a
dropdown. If you add the third form the page has the search results
form, the form with the dropdown and the search form, in that order.
The save button is set to submit the search results, which is always
forms[0]. If the page has all 3 forms, it works fine. The first form
is submitted,and it is the correct form. If however, the page only has
2 forms, the search results form is ignored, and the form submitted as
forms[0] is the second form, the search form.
document.forms.length is 2 so there does indeed seem to be 2 forms.
What happened to the first form ? Why is it being ignored.

Source/URL?

Sorry, I can't post the url. I have tried but I am not able to make a
simple test case. Every time I do it works fine.
 
T

Thomas 'PointedEars' Lahn

[...]
document.forms.length is 2 so there does indeed seem to be 2 forms.
What happened to the first form ? Why is it being ignored.
Source/URL?
[...]

Sorry, I can't post the url. I have tried but I am not able to make a
simple test case. Every time I do it works fine.

Certainly you can provide the full source of your HTML document using a
public URI. If not, you have to try the http://validator.w3.org/ yourself.
This is likely not to be a script issue but a case of invalid markup.

Please quote only the minimum of what you are replying to in order to retain
the context of your reply.


PointedEars
 
E

Evertjan.

wrote on 05 aug 2007 in comp.lang.javascript:
Does anyone recognize this situation and know what causes it ?
The page starts with just a search form. When you do a search the page
now has a search results form, a save botton, and the search form at
the bottom. There is also a link to add another form with a
dropdown. If you add the third form the page has the search results
form, the form with the dropdown and the search form, in that order.
The save button is set to submit the search results, which is always
forms[0]. If the page has all 3 forms, it works fine. The first form
is submitted,and it is the correct form. If however, the page only has
2 forms, the search results form is ignored, and the form submitted as
forms[0] is the second form, the search form.
document.forms.length is 2 so there does indeed seem to be 2 forms.
What happened to the first form ? Why is it being ignored.

Source/URL?

Sorry, I can't post the url. I have tried but I am not able to make a
simple test case. Every time I do it works fine.

Ah, the dreaded borderline effect!

The only effect in javascriptingdom where neither John nor Randy has found
a cure for.

The only solution seems not to make a simple test case, so it won't work
fine every time.
 
G

groups2

Ah, the dreaded borderline effect!

The only effect in javascriptingdom where neither John nor Randy has found
a cure for.

The only solution seems not to make a simple test case, so it won't work
fine every time.

I figured out the problem. The second form was recontructed depending
on what was posted. The contents of the div that contained the second
form was first deleted and then a query string was constructed based
on the form number of the form that no longer existed.
I took out the line that deleted the form. It doesn't seem neccesary,
since the form is going to be rewritten anyway a millesecond later.
 

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

Staff online

Members online

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,414
Latest member
GayleWedel

Latest Threads

Top