I strongly suggest to use DOM object model when programming
JavaScript, since I do it my applications are accessed from Safari,
IE, Firefox without problems and no browser dependent code is
required. In your case I'd do this:

1. The html form:

<html:form action="/editRegistration"
onsubmit="validateRegistrationForm(this)" styleId="myFrm">

Note that I have added the styleId attribute, this will be rendered as
an id attribute when html is generated. The id attribute identify your
html node in the node tree (in this case the form node).

2. The javascript function callDelete: we use DOM
(http://www.w3.org/DOM) to locate a node and change its attributes:
 
function callDelete() {
  frm = document.getElementById("myFrm");  
  frm.setAttribute("action", "/deleteRegistration");
  frm.submit();
}

* With document.getElementById("...") you can locate an object of your
html document if it has an id attribute.
* With node.setAttribute(attributeName, value) you can modify the
value of an attribute or add it if it doesn't exists.
* And there are many other useful and simple methods you can use like
getElementsByTagName, appendChild ... Try this for more information
http://www.scottandrew.com/weblog/articles/dom_2

Hope this help.





On Wed, 29 Sep 2004 16:29:39 -0400, Shabada, Gnaneshwer
<[EMAIL PROTECTED]> wrote:
> All.
> 
> I am posting again so that someone can shed some light on this..
> 
> I am trying to submit an action from a button thru a Javascript function.
> 
> My Javascript code is :
> 
> function callDelete()
> {
>         document.forms[0].action="/deleteRegistration";
>         document.forms[0].submit(); ----> JS error
> }
> 
> 
> My JSP code is something like this:
> 
> <html:form action="/editRegistration"
> onsubmit="validateRegistrationForm(this)">
>  .
>  so on..
>  .
>  .
>  .
> <html:submit property="submit">
> <bean:message key="button.update" />
> </html:submit>
> <html:submit onclick="javascipt:callDelete();">
> <bean:message key="button.delete" />
> </html:submit>
> </html:form>
> 
> When I click the UPDATE button, the default "/editRegistration" action is
> called. But when I click the Delete button I want to submit the
> "/deleteRegistration" thru JS function. I don't know why but I am getting
> this browser Javascript error saying "Object doesn't support this property
> or method" on the submit line (shown above). Am I doing anything wrong? Does
> struts html form support javascript action submission. Is there any other
> way to do this?
> 
> Please help
> 
> 
> Gnan
> 
> ========================================================================
> This email message is for the sole use of the intended recipient (s) and may
> contain confidential and privileged information. Any unauthorized review,
> use, disclosure or distribution is prohibited. If you are not the intended
> recipient, please contact the sender by reply email and destroy all copies
> of the original message. To reply to our email administrator directly, send
> an email to [EMAIL PROTECTED]
> Toys "R" Us, Inc.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to