You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ramadoss Chinnakuzhandai <rc...@register.com> on 2004/04/02 21:07:29 UTC

Form submit in JavaScript

Hi,

I have the following block of code in my jsp

<tr>
 <td colspan="3" align="right">
	<html:submit property="command" value="Delete" onclick="sumbitForm('Delete');return true;"/>
	<html:submit property="command" value="Cancel" onclick="sumbitForm('Cancel');return true;"/>
	<html:submit property="command" value="Save" onclick="sumbitForm('Save');return true;"/>					
</td>	
</tr>


I hv the following JavaScript function inside the same jsp

<script language="javascript">
    function submitForm(input) {       
	   var action;
	   if(input == "Delete") {action = "/tools/admin_employees.rcmx?method=deleteUser";}
	   else if(input == "Cancel") {action = "/tools/admin_employees.rcmx?method=displayUsers";}
	   else if(input == "Save") {action = "/tools/admin_employees_edituser?method=updateCsrAccount";}		   
	   document.manageCsrAccountsForm.action = action;
	   document.manageCsrAccountsForm.submit();
	   return true;	   
    }
</script>


When I click on Delete/Cancel/Save button it does not actually invoke javascript function but submit to the action specified in the <html:form action="action">.

Can anybody guide me where I'm doing wrong...or any better way to do this?

Thank for your time,

-Ramadoss


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org