2011-06-22 54 views
3

我正在创建一个动态表单来提交几个输入元素,但它不发送请求。我用fiddler检查为什么我的动态表单没有被提交?

这里是我的代码

var form_ref = document.createElement("form"); 
form_ref.id = "viewform"; 
form_ref.name = "viewform"; 
form_ref.action = "/csm/showResult.action"; 
form_ref.method = "post"; 
form_ref.target = "_self"; 

var cfgidField = document.createElement("input"); 
cfgidField.name = "cfgid"; 
cfgidField.type = "text"; 
cfgidField.value = configid; 
form_ref.appendChild(cfgidField); 

var cfgnameField = document.createElement("input"); 
cfgnameField.name = "cfgname"; 
cfgnameField.type = "text"; 
cfgnameField.value = configname; 
form_ref.appendChild(cfgnameField); 

var cfgdescField = document.createElement("input"); 
cfgdescField.name = "cfgdesc"; 
cfgdescField.type = "text"; 
cfgdescField.value = configdesc; 
form_ref.appendChild(cfgdescField); 

var cfgenvField = document.createElement("input"); 
cfgenvField.name = "cfgenv"; 
cfgenvField.type = "text"; 
cfgenvField.value = configenv; 
form_ref.appendChild(cfgenvField); 

var cfgfileField = document.createElement("input"); 
cfgenvField.name = "cfgfile"; 
cfgenvField.type = "text"; 
cfgenvField.value = absolutepath; 
form_ref.appendChild(cfgfileField); 

var cfgdateField = document.createElement("input"); 
cfgenvField.name = "updatedDate"; 
cfgenvField.type = "text"; 
cfgenvField.value = absolutepath; 
form_ref.appendChild(cfgdateField); 

form_ref.submit(); 

回答

相关问题