PDA

View Full Version : How to disable textfield if radio button is selected?



JohnJones357
6 Feb 2014, 9:34 AM
Basically, I have a field set with a radio button and 2 textfields. If user selects the radio button, I want to disable the other two textfields.

Also, How can I make my single radio button 'unselectable'? Once button is selected, I want it to be unselected if its clicked again in which case, both textfields will also need to be re-enabled.

thanks in advance!

scottmartin
6 Feb 2014, 9:40 AM
See if this helps:
http://www.sencha.com/forum/showthread.php?242007

JohnJones357
6 Feb 2014, 11:22 AM
Scott,

Thanks for the link but unfortunately I am unable to access it....something about not having sufficient privileges. If someone who has access to it can C&P relevant snippets from that thread that will be great!

thanks

scottmartin
6 Feb 2014, 11:38 AM
Code:



var panel = Ext.create ('Ext.container.Container', {
renderTo: Ext.getBody () ,
items: [
{
xtype: 'radiogroup',
fieldLabel: 'Select',
columns: 1,
vertical: true,
items: [
{
boxLabel: 'Value 1',
inputValue: '1',
checked: true,
name: 'inputname',
listeners: {
change: function (field, newValue, oldValue) {
if (newValue) panel.down('textfield').hide();
}
}
},
{
boxLabel: 'Other',
inputValue: '2',
name: 'inputname',
listeners: {
change: function (field, newValue, oldValue) {
if (newValue) panel.down('textfield').show();
}
}
}
]
},
{
xtype: 'textfield',
hidden: true, // or use disabled; and set enable(),disable()
fieldLabel: 'My Text'
}
]
});