I have developed one JSP page having HTML and JavaScript in it. Here is the excerpt of page.
Here when I click on submit button, it submit the first form and executes logout.htm. But when I changed that first form to,
It has started working correctly.
What could be the possible reason for this?
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
6
posted
0
It is invalid markup to have a form nested in another. Read the HTML Spec.
Eric
Vikas Kapoor
Ranch Hand
Joined: Aug 16, 2007
Posts: 1374
posted
0
Eric,
there is no nested form. Please look at the code carefully.
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
6
posted
0
Well I am going by what you posted and you are not showing all of the mark-up / closing tags so I am going off of what people have done in the past in forums.
Looking at your code in your post, your markup looks bad, you can not have the form tag around table cell like that. It would have be entirely in the cell or around the whole table.
And when it fails do you get any JavaScript errors?
Eric Pascarello wrote:Looking at your code in your post, your markup looks bad, you can not have the form tag around table cell like that. It would have be entirely in the cell or around the whole table.
I use table for alignment of elements (I don't know div tag properly).So very first tag after body tag is table tag and I adjust all the elements in it. So it is obvious that form tag might come under some td tag and the same td tag may contain another table. In my case it's like this ,
Second Form
Excerpt of Header.jsp
So at the run time everything will be merged in single page. And everything looks fine.
Isn't this the proper way of alignment of elements? Please guide me if I am wrong. Please justify your statment.
Eric Pascarello wrote:And when it fails do you get any JavaScript errors?
Except the line in header.jsp, I didn't use javascript atall in this page. Actually, I don't get any error atall but it behaves unexpectedly. When I submit the button(I'm done) then it should submit the second form and hence it should call the controller associated to that pattern. But in my case it submit the first form and call the logout controller.
Vikas Kapoor
Ranch Hand
Joined: Aug 16, 2007
Posts: 1374
posted
0
Bear Bibeault wrote:Yes, look at the HTML code carefully. Your first example is invalid!
Bear, Form tag is closed properly and there no nesting of forms. What is invalid in that?
Bauke Scholtz
Ranch Hand
Joined: Oct 08, 2006
Posts: 2458
posted
0
The HTML <form> element doesn´t allow a shorttag. Use <form></form> instead of <form />.