用javascript 如何为一个制定的form 增加一个隐藏域?
类似增加一个<INPUT TYPE="hidden" NAME="">,谢谢

解决方案 »

  1.   

    <html>
    <head>
    <title> test</title>
    <script>
    function add(){
    var oBtn = document.createElement('input');
    oBtn.type="hidden";//可将hidden换成button测试下
    document.form1.appendChild(oBtn);
    }</script>
    </head>
    <body >
    <form name="form1"><input type="button" value="add" onclick="add()"></body>
    </html>
      

  2.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">  
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>政府信息公开</title>
    <link href="index.css" rel="stylesheet" type="text/css">
    <script   language="javascript">   
       function addInput(){
    var frm=document.forms[0];
    var newInput=document.createElement("input");
    newInput.type="hidden";
    newInput.name='nn';
    frm.appendChild(newInput);
    }
    window.onload=addInput;
      </script></head>
    <body bgcolor="#FFFFFF">
    <form >
     <input type='text'>
    </form>
    </body>
    </html>