alert(document.getElementsByName("readonly")[0].value);

解决方案 »

  1.   

    alert(document.getElementsByName("readonly").value+"");
      

  2.   

    你要放在<body onload='alert(document.getElementsByName("readonly")[0].value);'>里执行,否则对象没有生成就调用会出问题
      

  3.   

    楼上废话
    element明显已经在js载入前解释了
      

  4.   

    楼主明显应该把生成的htm代码贴出来!
      

  5.   

    <xsl:element name="input">
      <xsl:attribute name="type">hidden</xsl:attribute>
      <xsl:attribute name="name">readonly</xsl:attribute>
      <xsl:attribute name="value">
      <xsl:value-of select="readonly"/>
      </xsl:attribute>
    </xsl:element>等于<input type="hidden" name="readonly" value="值" />
      

  6.   

    1. element放到了body外面
    2. getElementsByName("readonly")返回的是一个集合 应该用
       getElementsByName("readonly")[0].value
      

  7.   

    解决了,是语句写错了,应该是 getElementsByName("readonly")[0].value;另外我试了一下发现Element是不是放在body里面好像没关系,只要在JavaScript之前就行。谢谢各位了!