我想用JavaScript中的document.getElementById("name");
获得name : <html:text property="user.name" onblur="testAjax()" />
我应该在sturts标签中添加那个属性?
大哥大姐帮帮忙吧!!!

解决方案 »

  1.   

    不行啊!
    它返回object啊!
      

  2.   

    <html:text property="user.name" onblur="testAjax(this.value)" />
    就行了,也省的拿了
      

  3.   

    <html:text property="user.name" styleId="name" onblur="testAjax()" /> 
    document.getElementById("name");  这里得到了 这个文本域的对象,你还想得到什么??
      

  4.   

    真要那的话,加id呗
    <html:text property="user.name" id="name" onblur="testAjax()" />
    或者用dom,document.getElementsByTagName('html:text');
      

  5.   

    alert(document.getElementById("name").value);
      

  6.   

    它确实生成了 id=“name”,可是就是JavaScript中获得不到啊!
    它struts是这样的:
    name : <html:text property="user.name" onblur="testAjax()" styleId="name" />
    运行后:
    name : <input type="text" name="user.name" value="" onblur="testAjax()" id="name">
    可是它就是不对啊!
      

  7.   

    html:text新加入了id这个属性了?呵呵,styleId到看过....<html:text property="user.name" styleId="name" onblur="testAjax()" />取得值方法是:document.getElementById('name').value;
      

  8.   

    document.all("user.name").value;这样可以获取struts标签里的值