1. #1
    Ext User
    Join Date
    Apr 2007
    Posts
    189
    Vote Rating
    0
    captainm1uk is on a distinguished road

      0  

    Question Enable then disable a field

    Enable then disable a field


    Hi

    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 audit text is placed in there also. This works well until the form is saved - no data is saved with the form 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
    PHP Code:
     var grow = new Ext.form.TextArea({
       
    disabledtrue,
       
    autoHeightfalse,
        
    allowBlank:false,
             
    width:600grow:true
        
    });
    grow.applyTo('Comments'); 
    Here is the code for the message box

    PHP Code:
    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,
                
    buttonsExt.MessageBox.OKCANCEL,
                
    multilinetrue,
                
    fnshowResultText1.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

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


  2. #2
    Ext JS Premium Member dogomatic's Avatar
    Join Date
    Aug 2007
    Location
    Canada
    Posts
    111
    Vote Rating
    1
    dogomatic is on a distinguished road

      0  

    Default


    How about making the textarea readonly instead of disabled?

    instead of this:
    Ext.TextArea({disabled: true})
    try:
    Ext.TextArea({readOnly: true})

    Unlike a disabled field, a readonly field *will* be included as a parameter in a submit.

  3. #3
    Ext User
    Join Date
    Apr 2007
    Posts
    189
    Vote Rating
    0
    captainm1uk is on a distinguished road

      0  

    Default


    Your a star

    Thanks - I didn't know that existed


Thread Participants: 1