• 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

Problem with <html:button .....

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 .
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic