表单提交
一般 表单提交的时候 都是 名称:内容的 格式
这里因为我js中各个控件的名称都和数据库中字段名称不一样 我想提交的时候 我可以指定名称 比如提交 可以是 我指定的名称:内容
代码如下:
[code="java"]
function Employee_ShowAddEmployeeForm()
{
//-->页面
var Employee_ShowAddEmployeeForm_OKButton = new Ext.Button({
id : 'Employee_ShowAddEmployeeForm_OKButton',
name : 'Employee_ShowAddEmployeeForm_OKButton',
text : '提 交',
minWidth : 100,
listeners : {
'click' : function(o,e){Employee_ShowAddEmployeeForm_AddEmployee();}
}
});
var Employee_ShowAddEmployeeForm_CancelButton = new Ext.Button({
id : 'Employee_ShowAddEmployeeForm_CancelButton',
name : 'Employee_ShowAddEmployeeForm_CancelButton',
text : '取 消',
minWidth : 100,
listeners : {
'click' : function(o,e){
if (New_EmployeeForm){
New_EmployeeForm.close();
}
}
}
});
。。。。。
var Employee_ShowAddEmployeeForm_Panel = new Ext.form.FormPanel({
id : 'Employee_ShowAddEmployeeForm_Panel',
name : 'Employee_ShowAddEmployeeForm_Panel',
frame : true,
border : false,
labelAlgin:'right',
items : [
{layout:'column',border:false,items:[
{columnWidth:.5,layout:'form',border:false,items:[
Employee_ShowAddEmployeeForm_CName
]},
{columnWidth:.5,layout:'form',border:false,items:[
Employee_ShowAddEmployeeForm_EName
]}
]}
。。。。。
]});
//提交
temp_NewEmployeePanel.getForm().doAction('submit',
{
url : 'JSON/System/Employee.aspx',
mothed:'POST',
waitMsg:'正在提交。。。',
params : {FunctionName : 'Sys_Employee_AddEmployee'},
success : function(form, action){
var json = action.result.success;
if (json){
Ext.Msg.alert('系统提示','新职员数据成功!');
temp_NewEmployeePanel.getForm().reset();
}
else{
Ext.Msg.alert('系统提示','数据提交失败,请重试!');
}
},
failure : function(form, action){
Ext.Msg.alert('系统提示','与服务器交互失败,请检查连接是否正常!');
}
});
[/code]
[code="java"]
params : {
"publicStore.publicSceneId" :publicSceneId,
"publicStore.sceneName" :sceneName,
"publicStore.description" :description,
"publicStore.url" :url,
"publicStore.serverId" :serverId,
"publicStore.templateId" :templateId
},
[/code]
先用Ext.fly('publicSceneId').dom.value将值赋给publicSceneId
然后params自己想用什么名字就用什么名字,对应后台接受的名字。
[quote]
/**
- add a public store with current store to database
-
*/
function saveOrUpdatePublicStore() {
checkIsLogin();
var publicSceneId = Ext.fly("public_store_id").dom.value;
var sceneName = Ext.fly("public_store_name").dom.value;
var description = Ext.fly("public_store_desc").dom.value;
var url = Ext.fly("public_store_url").dom.value;
var serverId = Ext.fly("public_store_server").dom.value;
var templateId = Ext.fly("public_store_template").dom.value;Ext.Ajax.request( {
url :"checkUrlOfScene.do",
method :"POST",
params : {
"publicStore.url" :url,
_ts :new Date().getTime()
},
callback : function(op, succ, response) {
data = Ext.util.JSON.decode(response.responseText);
if (succ) {
if(data.success){
Ext.Ajax.request( {
url :"saveOrUpdatePublicStore.do",
method :"POST",
params : {
"publicStore.publicSceneId" :publicSceneId,
"publicStore.sceneName" :sceneName,
"publicStore.description" :description,
"publicStore.url" :url,
"publicStore.serverId" :serverId,
"publicStore.templateId" :templateId
},
callback : function(options, success, response) {
result = Ext.util.JSON.decode(response.responseText);
if (success == true) {
Ext.Msg.alert('Information', result.info);
// TO DO
} else {
Ext.Msg.alert('Error', data.info).setIcon(Ext.MessageBox.ERROR);
}
}
});
}
else
Ext.Msg.show( {
title :'Failed',
msg :data.info,
buttons :Ext.Msg.OK,
icon :Ext.MessageBox.WARNING ,
minWidth :"220px"
});
return false;
} else {
Ext.Msg.show( {
title :'Error',
msg :data.info,
buttons :Ext.Msg.OK,
icon :Ext.MessageBox.ERROR,
minWidth :"220px"
});
return false;
}
}
});
}
[/quote]