<html>
<head>
<script type="text/javascript" >
  function doEdit(){
     var value1 = document.frm.input1.value;
     if(value1 == "hidden"){  
        html = "<input type='hidden' name='input2'>";  
     }else if(value1 == "text"){
        html = "<input type='text' name='input2'>";
     }
     document.all.aa.innerHTML = html;
     document.frm.input1.value = "";
     document.frm.input1.focus();
  }
</script>
</head>
<body>
<form name="frm">
<table>
<tr>
<td><input type="text" name="input1"></td>
<td><div id="aa"><input type="text" name="input2"></div></td>
<td><input type="button" name="btn" value="submit" onclick="doEdit();" /></td>
</tr>
</table>
</form>
</body>
</html>