不好意思少写点 我的意思是说在js里面获得test文本框的值!我写的js获得值的时候有问题,获得不了.

解决方案 »

  1.   

    此问题如果想直接获得可以这样:1、<html:text property="userName"  id=“xingming”/>设置个ID
    2、js中获得此ID值如下:document.getElementById("xingming").value
      

  2.   

    function sub(){
    var ch=document.form[0].element[1];
    alert(ch);
    }
    少一个s,应该是document.forms[0].element[1];它的第一个元素会不会是table啊
      

  3.   

    应该是这样吧<html:text property="userName"  styleid=“xingming”/>
    或者这样取
    document.all("userName").value
      

  4.   

    document.getElementById("xingming").value
      

  5.   

    你在IE查看中看一下生成的HTML源代码
    taglib标签都换成了HTML标签
    在〈FORM 。〉这里你可以看到它的NAME属性,这个属性的值和你的ACTION所用的ACTIONFROM的名字是一样的
    知道NAME属性以后(比如formname),你就可以这样写:formname.userName.value
      

  6.   

    1、获得test文本框的值:
       
     document.forms[0].userName.value
     或者:document.getElementById("userName").value2、要想获得<html:select property="select"> 
               <html:option value="1">1</html:option>
           </html:select>中的值: document.getElementById("select").value
      

  7.   

    <html:form action="/Logon.do" name="logonform" 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>document.logonform.userName.value
    document.logonform.userPws.value
      

  8.   

    document.forms[0].userName.value
    forms[0]:你第一个form
      

  9.   

    为控件加一个name属性或者styleid属性,然后在js中使用getElementByNames或getElementById