PDA

View Full Version : Enable then dsable a field - FIXED



captainm1uk
22 Nov 2007, 4:06 AM
I have also added this to the ext 1.1 forum as it applies to both

I have a field on a form which is disabled (as I want a certain form and style of text placed in there) - when the user presses a button, they get a popup box and they type in there. When they press OK that text gets written back to the field and some autid text is placed in there also. This works well until the doc is saved - no data is saved with the doc as the field is read only. Is it possible that in the fuction that writes the text back to the field, enable the field, write the text then disable it again

This is the code for the field


var grow = new Ext.form.TextArea({
disabled: true,
autoHeight: false,
allowBlank:false,
width:600, grow:true
});
grow.applyTo('Comments');


Here is the code for the message box



var btn1 = new Ext.Button('mb2', {text: 'Add your Comments' , handler :
function(e){
Ext.MessageBox.show({
title: 'Comments',
msg: 'Please enter you ideas/ comments',
width:400,
buttons: Ext.MessageBox.OKCANCEL,
multiline: true,
fn: showResultText1.createDelegate(this), // Set scope or 'this' in function to scope of this function which is Comments
animEl: 'mb2'
})}, scope : grow});


Here is the code for the function that is called



function showResultText1(btn1, text){
if(btn1=='ok'){
this.setRawValue(this.getRawValue()+"Comments added by "+ authorName+ " on "+ myDate +"\r"+text+"\r"+"\r");
this.autoSize(); // Grow field
}

captainm1uk
23 Nov 2007, 1:39 AM
I have tried the following but with no success
this.enable();
this.setRawValue(....);
this.disable();

But with no success - is there any way of doing this

jratcliff
23 Nov 2007, 10:40 AM
are you sure your data is actually getting posted to the server for this field?

captainm1uk
23 Nov 2007, 2:03 PM
posituve

If i just use this.enable.... it enables the field and saves the data but if i set it to disable at the end - none of it saves

Basically i need to make the field read only so they cannot edit it - if there is another way round

Zakaroonikov
23 Nov 2007, 10:00 PM
Can you not enable the fields as part of your submit routine?

captainm1uk
24 Nov 2007, 1:25 AM
i can do but i don't want them to type in the field at any point before the submit

Zakaroonikov
24 Nov 2007, 7:48 PM
Perhaps hide it then enable it then submit?

captainm1uk
25 Nov 2007, 2:35 AM
Would that work if i have a computed field looking up to it only showing if the editable one is hidden ?

Zakaroonikov
25 Nov 2007, 1:11 PM
Would that work if i have a computed field looking up to it only showing if the editable one is hidden ?

No as the computed field will not automatically be updated. The field will only have the value that it gets onload.

captainm1uk
25 Nov 2007, 3:09 PM
so i am back to square one again - is there any other way i can get round this ?

Zakaroonikov
26 Nov 2007, 12:44 PM
Have about instead of disabling the field make it readonly:

http://www.htmlcodetutorial.com/forms/_INPUT_DISABLED.html

That way it cannot be typed to yet it still gets submitted?

captainm1uk
26 Nov 2007, 12:51 PM
Could i render this field like the others - it using the ext style ?

Zakaroonikov
26 Nov 2007, 1:27 PM
Could i render this field like the others - it using the ext style ?

I think so. Only one way to find out

captainm1uk
26 Nov 2007, 1:28 PM
true - will test it tomorrow and see

captainm1uk
26 Nov 2007, 2:17 PM
Hi

Just checked the other forum and suggested I can use instead of disabled: true, use readOnly: true and this will get submitted

Will try and confirm

captainm1uk
27 Nov 2007, 3:29 AM
Confirmed it does work - so no need to enable then disable the field.

:)