PDA

View Full Version : who caan teach me how i change the visibility after click button?



dannyg
3 Dec 2009, 1:39 AM
<html>
<head>
<title>Forms Example</title>
<link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
<script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../../ext-all.js"></script>
<script type="text/javascript" src="newjavascript.js"></script>
<script>
Ext.onReady(function(){

Ext.BLANK_IMAGE_URL = 'images/s.gif';
Ext.QuickTips.init();

var main_form = new Ext.FormPanel({
url: 'submit.php',
renderTo: document.body,
frame: true,
labelAlign: 'center',
title: 'New Project',
bodyStyle:'padding:10px',
width: 450,
items: [{
xtype: 'numberfield',
fieldLabel: 'Project ID',
name: 'project_id',
id: 'project_id',
value:123,
//disabled:true,
allowBlank: false
},{
xtype: 'numberfield',
fieldLabel: 'Number of step',
name: 'step_number',
id: 'step_number',
allowBlank: false,
value:123,
listeners: {
specialkey: function(f,e){
if (e.getKey() == e.ENTER) {
main_form.getForm().submit();
}
}
}
}],
buttons: [{
text: 'Proceed',
handler: function(a,b){
main_form.getForm().submit();
//what should i put here to set the field visibility?
}
}]
});
});
</script>
</head>
<body>
</body>
</html>

VinylFox
3 Dec 2009, 8:08 AM
You could use disable to disable the entire panel/form.


main_form.disable();

or just the button.


this.disable();

or just one of the fields in your form.


main_form.getForm().findField('project_id').disable();

Just about every ExtJS Component has a disable method you can call.

mschwartz
3 Dec 2009, 8:21 AM
You could use disable to disable the entire panel/form.


main_form.disable();or just the button.


this.disable();or just one of the fields in your form.


main_form.getForm().findField('project_id').disable();Just about every ExtJS Component has a disable method you can call.

Note that if you disable a form or form field and submit the form, those fields or the form won't be submitted. This is a major flaw, IMO.

dannyg
3 Dec 2009, 5:26 PM
i want to ask:
main_form.getForm().findField('project_id').disable();
findField('variable'),variable is name? or id?

it's work...

but y the button can function even i didn't enter any input? i want disable the text field after key in can?


<html>
<head>
<title>Forms Example</title>
<link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
<script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../../ext-all.js"></script>
<script>
Ext.onReady(function(){

Ext.BLANK_IMAGE_URL = 'images/s.gif';
Ext.QuickTips.init();

var main_form = new Ext.FormPanel({
url: 'form_danny.html',
renderTo: document.body,
frame: true,
labelAlign: 'center',
title: 'New Project',
bodyStyle:'padding:10px',
width: 450,
items: [{
xtype: 'numberfield',
fieldLabel: 'Project ID',
name: 'project_id',
//id: 'project_id',
allowBlank: false
},{
xtype: 'numberfield',
fieldLabel: 'Number of step',
name: 'step_number',
//id: 'step_number',
allowBlank: false,
listeners: {
specialkey: function(f,e){
if (e.getKey() == e.ENTER) {
main_form.getForm().submit();
}
}
}
}],
buttons: [{
text: 'Proceed',
handler: function(a,b){
main_form.getForm().submit();
main_form.getForm().findField('project_id').disable();
main_form.getForm().findField('step_number').disable();
}
}]
});
});
</script>
</head>
<body>
</body>
</html>