Why Javascript can't get value in Struts?
I have a button in Struts,when click this button,it will show a value in Struts,like follows:
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="form" %>
<script language="JavaScript">
function a(){
alert(username.value);
}
</script>
<form:form action="/register">
UserName:<form:text property="username"/>
enter password:<form:password property="password1"/>
re-enter password:<form:password property="password2"/>
<form:hidden property="abc" value="3"/>
<form:button property="button" value="Test" onclick="a()"/>
<form:submit value="Register"/>
</form:form>
But when I click Test button,it can't show the value of parameter "username",why? How to show the value of it?
I have a another question,how many attribute of the taglib <form:>? Is there a document for it?
Thanks!
But when I click Test button,it can't show the value of parameter "username",why? How to show the value of it?
Paz>>
<script language="JavaScript">
function a(){
[b]alert(document.forms[0].[/b]username.value);
}
</script>
I have a another question,how many attribute of the taglib <form:>? Is there a document for it?
Paz>>
http://struts.apache.org//struts-doc-1.1/userGuide/struts-html.html
Sorry Read this as :
But when I click Test button,it can't show the value of parameter "username",why? How to show the value of it?
Paz>>
<script language="JavaScript">
function a(){
alert(document.forms[0].username.value);
}
</script>
1) the textfield is part of a form. Normally you would access a form value through FORMNAME.username.value, but you don't define a formname so I think the same can be achieved through forms[0].username.value.
2) for documentation, how about the struts website ?
http://struts.apache.org/