<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD><BODY><INPUT TYPE="text" NAME="AA" id="AA" >
<INPUT TYPE="submit" onclick ="Test(AA.value)">
<HR><!-- 想在<HR> 后面再画a-1的 <HR> . 这样似乎不可以呀!-->
<SCRIPT LANGUAGE="JavaScript">
<!--
function Test(a)
{
var tmp = a-1;
if (tmp > 0)
{
while (tmp > 0)
{
document.write("<hr>");
tmp--;
}
}
}
//-->
</SCRIPT>
</BODY>
</HTML>
哦代码是这样的!
<FORM METHOD=POST ACTION="Noname3.html">
</FORM>
不要表单的

解决方案 »

  1.   

    document.write都已经把html重绘了.只有靠浏览器后退才能看到提交按钮,但一后退状态又回回到提交前.
      

  2.   

    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <!-- 想在<HR> 后面再画a-1的 <HR> . 这样似乎不可以呀!-->
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function Test(a)
    {
    var tmp = a-1;
    if (tmp > 0)
    {
    while (tmp > 0)
    {
    //document.write("<hr>");
    var o=document.getElementById("a");
    alert(o);
    var t=document.createElement("hr");
    o.appendChild(t);
    tmp--;
    }
    }
    }
    //-->
    </SCRIPT>
    </HEAD><BODY><INPUT TYPE="text" NAME="AA" id="AA" >
    <INPUT TYPE="button" onclick ="Test(AA.value)" value="add">
    <HR id="hr1">
    <div id="a"></div>
    </BODY>
    </HTML>
      

  3.   

    joohnnie的做法是正确的,这里只能动态创建HR对象然后把他们添加到DOM中。当文档已经装载完毕后,调用document.write()或者document.writeln()方法会把原来的文档内容覆盖掉。文档原文如下:write Method Writes one or more HTML expressions to a document in the specified window. Syntaxdocument.write(sText)
    ParameterssText Required. String that specifies the text and HTML tags to write. Return ValueNo return value.ResYou should not use the write or writeln methods on the current document after the document has finished loading unless you first call the open method, which clears the current document's window and erases all variables.Note  When document.write or document.writeln is used in an event handler, document.close should also be used.
    Standards InformationThis method is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 . 
      

  4.   

    to joohnnie第二次设置n个后,怎么把第一次设置的删除,设置第二次呀! 这个只能一直增加亚
      

  5.   

    可以在div里画:
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    </HEAD><BODY>
    <FORM METHOD=POST ACTION="Noname3.html">
    </FORM>
    <INPUT TYPE="text" NAME="AA" id="AA" >
    <INPUT TYPE="submit" onclick ="Test(AA.value)">
    <HR>
    <div id="draw_hr"></div>
    <!-- 想在<HR> 后面再画a-1的 <HR> . 这样似乎不可以呀!-->
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function Test(a)
    {
    var tmp_html="";
    for (var tmp=1; tmp<a; tmp++)
    {
    tmp_html+="<hr>";
    }
    draw_hr.innerHTML=tmp_html;
    }
    //-->
    </SCRIPT>
    </BODY>
    </HTML>
      

  6.   

    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <!-- 想在<HR> 后面再画a-1的 <HR> . 这样似乎不可以呀!-->
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function Test(a)
    {
    var o=document.getElementById("a");
    o.innerHTML="";
    var tmp = a-1;
    if (tmp > 0)
    {
    while (tmp > 0)
    {
    //document.write("<hr>");

    //alert(o);
    var t=document.createElement("hr");
    o.appendChild(t);
    tmp--;
    }
    }
    }
    //-->
    </SCRIPT>
    </HEAD><BODY><INPUT TYPE="text" NAME="AA" id="AA" >
    <INPUT TYPE="button" onclick ="Test(AA.value)" value="add">
    <HR>
    <div id="a"></div>
    </BODY>
    </HTML>