定义一个div style="display"然后做个js让它显示
解决方案 »
- axis2 和 spring 整合,有这方面经验和知道都请进来看看
- inputstream unknown source的问题
- 有关 weblogic,struts,struts标签,struts.taglib 的问题
- jasperreport在linux下报错?
- 高分求spring in action的源码...
- java新手求救
- MyEclipse debug时间过长为什么会卡死?
- 密碼問題,請幫解決一下,謝謝
- eclipse问题,请指教!
- 关于数据库批量插入操作的实现方式比较
- 如何在Java WEB系统中嵌入excel
- hibernate annotation onetomany级联保存问题
private String[] tname;
private int[] postcode;
private int[] sex;
private String[] work;在保存这些员工的时候循环这些数组获取每一个名称.
名字当然不能重复,你可以用你设置的变量i累加啊, 比如:
<TR>' +
'<TD align="center" colspan="4">个人信息 (' + i +')</TR>' +
'<TR>' +
'<TD align="right">姓名:</TD>' +
'<TD> <INPUT TYPE="text" NAME="tName" + i></TD>' +
后台定义两个处理单元(servletClass还是其他等等)一个是加公司,一个是加员工
然后前台页面显示目前的公司列表和员工列表,和两个添加按钮
点了添加后将对应添加表单的div的display置为visi,。,什么的,填好表单后调用js方法将数据组装后异步请求那两个处理单元中的一个。
最后再刷新公司和员工表的视图
动态无刷新发送请求并用alert显示操作结果
http://blog.csdn.net/plmxsyuts6/archive/2009/07/09/4334619.aspx
动态无刷新发送请求并用alert显示操作结果
http://blog.csdn.net/plmxsyuts6/archive/2009/07/09/4334619.aspx
期待高手的加入
一个人写的示例:
Ext.onReady(function() { Ext.QuickTips.init(); var StudentRecord = Ext.data.Record.create([
{name: 'id', type: 'int'},
{name: 'code', type: 'string'},
{name: 'name', type: 'string'},
{name: 'sex', type: 'string'},
{name: 'age', type: 'int'},
{name: 'political', type: 'string'},
{name: 'origin', type: 'string'},
{name: 'professional', type: 'string'}
]); var store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: 'student?action=list'}),
reader: new Ext.data.JsonReader({
totalProperty: 'totalProperty',
root: 'root'
},StudentRecord)
});
store.load(); // grid start
var grid = new Ext.grid.GridPanel({
region: 'center',
store: store,
columns: [
{header: '学号', dataIndex: 'code'},
{header: '姓名', dataIndex: 'name'},
{header: '性别', dataIndex: 'sex'},
{header: '年龄', dataIndex: 'age'},
{header: '政治面貌', dataIndex: 'political'},
{header: '籍贯', dataIndex: 'origin'},
{header: '所属系', dataIndex: 'professional'}
],
sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
viewConfig: {
forceFit: true
}
});
grid.getColumnModel().defaultSortable = true;
// grid end // form start
var form = new Ext.form.FormPanel({
region: 'east',
frame: true,
width: 300,
autoHeight: true,
labelAlign: 'right',
labelWidth: 60,
defaultType: 'textfield',
items: [{
xtype: 'hidden',
name: 'id'
},{
fieldLabel: '学号',
name: 'code',
allowBlank: false,
width: 200
},{
fieldLabel: '姓名',
name: 'name',
allowBlank: false,
width: 200
},{
fieldLabel: '年龄',
name: 'age',
xtype: 'numberfield',
allowNegative: false,
allowBlank: false,
width: 200
},{
fieldLabel: '性别',
name: 'sex',
xtype: 'combo',
store: new Ext.data.SimpleStore({
fields: ['text'],
data: [['男'],['女']]
}),
emptyText: '请选择',
mode: 'local',
triggerAction: 'all',
valueField: 'text',
displayField: 'text',
readOnly: true,
allowBlank: false,
width: 200
},{
fieldLabel: '政治面貌',
name: 'political',
xtype: 'combo',
store: new Ext.data.SimpleStore({
fields: ['text'],
data: [['群众'],['党员'],['团员']]
}),
emptyText: '请选择',
mode: 'local',
triggerAction: 'all',
valueField: 'text',
displayField: 'text',
readOnly: true,
allowBlank: false,
width: 200
},{
fieldLabel: '籍贯',
name: 'origin',
allowBlank: false,
width: 200
},{
fieldLabel: '所属系',
name: 'professional',
allowBlank: false,
width: 200
}],
buttons: [{
text: '添加',
handler: function() {
if (!form.getForm().isValid()) {
return;
}
if (form.getForm().findField("id").getValue() == "") {
// 添加
form.getForm().submit({
url: 'student?action=save',
success: function(f, action) {
if (action.result.success) {
Ext.Msg.alert('消息', action.result.msg, function() {
grid.getStore().reload();
form.getForm().reset();
form.buttons[0].setText('添加');
});
}
},
failure: function() {
Ext.Msg.alert('错误', "添加失败");
}
});
} else {
// 修改
form.getForm().submit({
url: 'student?action=update',
success: function(f, action) {
if (action.result.success) {
Ext.Msg.alert('消息', action.result.msg, function() {
grid.getStore().reload();
form.getForm().reset();
form.buttons[0].setText('添加');
});
}
},
failure: function() {
Ext.Msg.alert('错误', "添加失败");
}
});
}
}
},{
text: '重置',
handler: function() {
form.getForm().reset();
form.buttons[0].setText('添加');
}
},{
text: '删除',
handler: function() {
var id = form.getForm().findField('id').getValue();
if (id == '') {
Ext.Msg.alert('提示', '请选择需要删除的信息。');
} else {
Ext.Ajax.request({
url: 'student?action=remove',
success: function(response) {
var json = Ext.decode(response.responseText);
if (json.success) {
Ext.Msg.alert('消息', json.msg, function() {
grid.getStore().reload();
form.getForm().reset();
form.buttons[0].setText('添加');
});
}
},
failure: function() {
Ext.Msg.alert('错误', "添加失败");
},
params: "id=" + id
});
}
}
}]
});
// form end // 单击修改信息 start
grid.on('click', function() {
var selections = grid.getSelectionModel().getSelections();
var record = selections[0];
form.getForm().loadRecord(record);
form.buttons[0].setText('修改');
});
// 单击修改信息 end // layout start
var viewport = new Ext.Viewport({
layout: 'border',
items: [{
region: 'north',
contentEl: 'head'
}, grid, form, {
region: 'south',
contentEl: 'foot'
}]
});
// layout end
});