日期:2014-05-18  浏览次数:20621 次

js如何获得struts表单中的值(有答案直接给分)
jsp:
        <html:form   action= "/Logon.do "   method= "POST ">
            <table   border= "0 ">
                <tr>
                    <td> 姓名: </td>
                    <td> <html:text   property= "userName "   /> </td>
                </tr>
                <tr>
                    <td> 密码: </td>
                    <td> <html:password   property= "userPws "   /> </td>
                </tr>
                <tr>
                    <td> <html:submit property= "submit "   value= "submit "   onclick= "sub() "   /> </td>
                    <td> <html:cancel   /> </td>
                </tr>
            </table>
        </html:form>

<script   type= "text/javascript ">
function   sub(){
var   ch=document.form[0].element[1];
alert(ch);
}

</script>
  想获得姓名后面test文本狂的值,但是就是获得不了. 请教该怎么写.
 要想获得 <html:select   property= "select ">  
            <html:option   value= "1 "> 1 </html:option>
        </html:select> 中的值和是或的test的方法一样吗.


------解决方案--------------------
<html:form action= "/admin/Users.do?action=create " method= "post " focus= "loginName " onsubmit= "return validation(this) " >

<table width= "100% " height= "87 " border= "0 " cellpadding= "0 " cellspacing= "1 " bgcolor= "#0066CC ">

<tr>

<td height= "85 " valign= "top " bgcolor= "#FFFFFF ">

<table width= "100% " height= "80 " border= "0 " cellpadding= "4 " cellspacing= "1 " bgcolor= "#FFFFFF ">

<tr bgcolor= "#E2E9FA ">

<td width= "16% " height= "20 " align= "right "> <strong> 用户登陆名 </strong> : </td>

<td width= "84% "> <html:text property= "loginName " > </html:text> </td>

</tr>



</table> </td>

</tr>

</table>

<br>