• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[Solved] Unexpected behaviour of HTML

 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is invalid markup to have a form nested in another. Read the HTML Spec.

Eric
 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric,
there is no nested form. Please look at the code carefully.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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



 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, look at the HTML code carefully. Your first example is invalid!
 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The HTML <form> element doesn´t allow a shorttag. Use <form></form> instead of <form />.
 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Bauke,
How did you come to know about this fact? I have also learned HTML.

And bear, I guess you were pointing the same thing, right?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HTML != XML
 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:HTML != XML


I didn't understand your gesture. Do you mean this kinda stuff is feasible in XML but not in HTML. Please be clear and simple.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Clear and simple: HTML is not XML, do not expect it to act like it. Self-closing tags are a no-no.

Now XHTML is a different matter...
 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear,Bauke and Eric!
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vishal Pandya wrote:Hey Bauke,
How did you come to know about this fact? I have also learned HTML.

Learn the (X)HTML DTD out of head.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic