File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Using javascript in Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Using javascript in Struts" Watch "Using javascript in Struts" New topic

Using javascript in Struts

dina raj

Joined: Dec 06, 2005
Posts: 17
In my application, which uses struts, the javascript refers to where frmReset is the name of the form. But since I am using Struts I cannot use the Name attribute for the form. So how do I rewrite the javascript? Or can I specify the name of the form while using <html:form>
alec stewart stewart
Ranch Hand

Joined: Dec 23, 2003
Posts: 71
yes of course you can specify name as follows

<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<title>Sample Struts Application</title>
<html:form action="Name" name="nameForm" type="example.NameForm">
<table width="80%" border="0">
<td><html:text property="name" /></td>
<td><html:submit /></td>
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
If you don't specify a name in the html:form tag, the name of the form will be the name of the actionForm associated with the action in the struts-config.xml file. It's easy to see what name struts has given the form by using the "view source" function of your browser when the page is being displayed.

Consultant, Sima Solutions
pax smith
Ranch Hand

Joined: Dec 13, 2005
Posts: 45

You can use document.forms[0].text1.value="sss"

I agree. Here's the link:
subject: Using javascript in Struts
It's not a secret anymore!