• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

[Solved] Unexpected behaviour of HTML

 
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eric,
there is no nested form. Please look at the code carefully.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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



 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HTML != XML
 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bear,Bauke and Eric!
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
mooooooo ..... tiny ad ....
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic