• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with <html:button .....

 
Naveen Mishra
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm using struts 1.1 along with wsad 5.1.2
In jsp file there is a problem :

Following code does not allow me to submit the form (i'm using javascript for validation of the form . It gives error message ( in javascript) saying "Object does not support this property or method' at line
document.forms[0].submit();

///// pls read onclik as onclick





but , when I changed the property of button to some thing else it works fine...



what is wrong in giving property as some reserve keyword ? as it is passed to the tld as an String literal only .

any good reason which works behind the seen or some bug in tld ?

Thanks .
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This problem has nothing to do with the Struts tag libraries. It has to do with JavaScript.

The tag <html:button property="submit" /> will be rendered as <input type="button" name="submit>. In terms of JavaScript This means that you've replaced the submit property of the forms[0] object with a button object. In JavaScript, a method is a property, so the existing submit() method of forms[0] is also a property. When you add a button named "submit", you replace the submit() method with a button object, thereby making it impossible to submit the form through JavaScript.

The moral of the story: Never name a button "submit" on your form. Also avoid any of the form object's other method names such as reset, focus, etc.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!