码迷,mamicode.com
首页 > 编程语言 > 详细

用javascript动态创建并提交表单form,表格table

时间:2014-07-03 20:30:00      阅读:238      评论:0      收藏:0      [点我收藏+]

标签:blog   http   java   os   art   javascript   

<script>

//helper function to create the form
function getNewSubmitForm(){
var submitForm = document.createElement("FORM");
document.body.appendChild(submitForm);
submitForm.method = "POST";
return submitForm;
}

//helper function to add elements to the form
function createNewFormElement(inputForm, elementName, elementValue){
var newElement = document.createElement("<input name=‘"+elementName+"‘ type=‘hidden‘>");
inputForm.appendChild(newElement);
newElement.value = elementValue;
return newElement;
}

//function that creates the form, adds some elements
//and then submits it
function createFormAndSubmit(){
var submitForm = getNewSubmitForm();
createNewFormElement(submitForm, "field1", "somevalue");
createNewFormElement(submitForm, "field2", "somevalue");
submitForm.action= "someURL";
submitForm.submit();
}
</script>

<input type="button" value="Click to create form and submit" onclick="createFormAndSubmit()">

 

http://blog.csdn.net/honey_claire/article/details/7658490

http://bbs.csdn.net/topics/300212131

http://bbs.csdn.net/topics/390693892

http://www.aa25.cn/code/458.shtml

用javascript动态创建并提交表单form,表格table,布布扣,bubuko.com

用javascript动态创建并提交表单form,表格table

标签:blog   http   java   os   art   javascript   

原文地址:http://www.cnblogs.com/gyjWEB/p/3821088.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!