使用Extjs 创建了一个textarea,用来显示信息,然后还有一个文本输入框,
现在要求是,将文本框中输入的值,显示到textarea中,但是不能将上次输出的清除掉,
现在我的做法是 var SendCmd = new Ext.form.FormPanel({
aotoHeight : true,
baseCls : 'bottomback',
buttonAlign : 'center',
border : false,
bodyStyle : 'padding: 10px 10px 10px 20px;',
labelWidth : 2,
defaults : {
anchor : '95%',
allowBlank : false,
msgTarget : 'side'
},
items : [{
xtype : 'textarea',
id:'Result',
name : 'Result',
height : 200,
readOnly : true,
allowBlank : true
}, {
xtype : 'textfield',
emptyText : '请输入...',
name : "Task",
listeners : {'specialkey':function(_field,_e){
if (_e.getKey() == _e.ENTER){
var str = Ext.getCmp('Task').getValue();
Ext.getCmp('Result').setValue(str);
}
}}
}]
});但是这样写,他会将上次输入的清除了,只有本次输入的。
我要的结果是:
第一次:adb
第二次:adb
aaaaaaa
第三次:adb
aaaaaaa
eeeeee就是说,,前面输入的还在,,怎么搞啊?
现在要求是,将文本框中输入的值,显示到textarea中,但是不能将上次输出的清除掉,
现在我的做法是 var SendCmd = new Ext.form.FormPanel({
aotoHeight : true,
baseCls : 'bottomback',
buttonAlign : 'center',
border : false,
bodyStyle : 'padding: 10px 10px 10px 20px;',
labelWidth : 2,
defaults : {
anchor : '95%',
allowBlank : false,
msgTarget : 'side'
},
items : [{
xtype : 'textarea',
id:'Result',
name : 'Result',
height : 200,
readOnly : true,
allowBlank : true
}, {
xtype : 'textfield',
emptyText : '请输入...',
name : "Task",
listeners : {'specialkey':function(_field,_e){
if (_e.getKey() == _e.ENTER){
var str = Ext.getCmp('Task').getValue();
Ext.getCmp('Result').setValue(str);
}
}}
}]
});但是这样写,他会将上次输入的清除了,只有本次输入的。
我要的结果是:
第一次:adb
第二次:adb
aaaaaaa
第三次:adb
aaaaaaa
eeeeee就是说,,前面输入的还在,,怎么搞啊?
aotoHeight : true,
baseCls : 'bottomback',
buttonAlign : 'center',
border : false,
bodyStyle : 'padding: 10px 10px 10px 20px;',
labelWidth : 2,
defaults : {
anchor : '95%',
allowBlank : false,
msgTarget : 'side'
},
items : [{
xtype : 'textarea',
id:'Result',
name : 'Result',
height : 200,
readOnly : true,
allowBlank : true
}, {
xtype : 'textfield',
emptyText : '请输入...',
name : "Task",
listeners : {'specialkey':function(_field,_e){
if (_e.getKey() == _e.ENTER){
var str += Ext.getCmp('Task').getValue();
Ext.getCmp('Result').setValue(str);
}
}}
}]
});
aotoHeight : true,
baseCls : 'bottomback',
buttonAlign : 'center',
border : false,
bodyStyle : 'padding: 10px 10px 10px 20px;',
labelWidth : 2,
defaults : {
anchor : '95%',
allowBlank : false,
msgTarget : 'side'
},
items : [{
xtype : 'textarea',
id:'Result',
name : 'Result',
height : 200,
readOnly : true,
allowBlank : true
}, {
xtype : 'textfield',
emptyText : '请输入...',
name : "Task",
listeners : {'specialkey':function(_field,_e){
if (_e.getKey() == _e.ENTER){
var str = Ext.getCmp('Result').getValue()+Ext.getCmp('Task').getValue();
Ext.getCmp('Result').setValue(str);
}
}}
}]
});
你既然想保留原先的值,那就先获取textarea原先的值,再加上现在输入的值
Ext.onReady(function(){
var SendCmd = new Ext.FormPanel({
aotoHeight:true,
buttonAlign:'center',
border:false,
bodyStyle:'padding: 10px 10px 10px 20px;',
labelWidth :2,
defaults:{
anchor : '95%',
allowBlank : false,
msgTarget: 'side'
},
items:[{
xtype : 'textarea',
id:'Result',
name : 'Result',
height : 200,
readOnly : true,
allowBlank : true
}, {
xtype:'textfield',
emptyText : '请输入...',
name:"Task",
id:"Task",
listeners:{'specialkey':function(_field,_e){
if (_e.getKey() == _e.ENTER){
var str = Ext.getCmp('Result').getValue()+'\r\n'+Ext.getCmp('Task').getValue();
Ext.getCmp('Result').setValue(str);
}
}}
}]
});
var win=new Ext.Window({
layout:'fit',
title:"test",
width:620,
height:350,
constrain: true,
resizable:false,
collapsible:true,
closable:true,
items:SendCmd
});
win.show();
});