javascript 动态创建Form

javascript 动态创建Form
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>js run</title>
</head>
<script type="text/javascript">
function createForm(){
var form1=document.createElement("form");
document.body.appendChild(form1);
form1.method="POST";
alert(form1)
return form1;
}
function createFormElement(from3,elementName,elementValue){
var element=document.createElement("input");
element.name=elementName;
element.value=elementValue;
from3.appendChild(element);
return element;
}
function createFormSubmit(){
var form5=createForm();
createFormElement(form5,"username","abin");
createFormElement(form5,"password","varyall");
form5.action="success.jsp";
form5.submit();
}
</script>
<body>
<input type="button" value="提交FORM" onclick="createFormSubmit()" />
<br>
下面就是要创建的输入框
<br>
<div id="div1">
</div>
<br>
333
</body>
</html>

你可能感兴趣的:(javascript 动态创建Form)