Announcement

Collapse
No announcement yet.

Enable/Disable Read-Only

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Enable/Disable Read-Only

    How can I create a button on a Form that changes some fields from read-only to non?

    I know there is a scriptcase macro to perform that but can be attached to a specific event.

    Can the above be achieved?

  • #2
    sc_field_disabled("Field_Name = True/False", "Parameter")

    This macro its used to block a field to get any data that would be typed on it.

    Fields that its going to be blocked should be followed by the option "true" (default) or "false".

    The parameter its optional, "I" its used only to block de addition of new records, "U" to block only the update, in case of the parameter has not been informed the scriptcase will use both options.

    Ex. 1: Blocks only one field for addition and update.
    sc_field_disabled("Field_01");

    Ex. 2: Unblocking a field for addtion and update.
    sc_field_disabled("Field_02=false");

    Ex. 3: Blocks several fields, only for update.
    sc_field_disabled("Field_01; Field_02; Field_03", "U");

    Ex. 4: Combination of block and unblock of several fields, for adition and update.
    sc_field_disabled("Field_01=true; Field_02=false; Field_03=true");

    I am assuming you want non readonly back to readonly. So you may on the On ApplicationInit or the OnScriptInit want to set them on readonly via a parameter...

    Comment


    • #3
      Thanks for the prompt reply rr, but what I need is to have a button on the form, display a confirmation message and then enable/disable the fields without reload if possible.

      Essentially OnClick for Button run the sc_field_disabled macro without reloading page.

      Comment


      • #4
        Hi,
        place a Javascript button on your form.

        Javascript-Code:

        if(document.F1.yourfield.disabled)
        {
        document.F1.yourfieldname.diesabled = false;
        }
        else
        {
        document.F1.yourfieldname.disabled = true;
        }

        That should give you a start.

        jsb

        Comment


        • #5
          Thanks jsb, but does F1 refer to the scriptcase form name and yourfieldname to exact field name or is there some specific notation required to access the form and field objects?

          Tried the recommended above replacing F1 with form name and yourfieldname with the field name but to no effect. The JS code provided was listed in the JS Code section of the button created.

          Comment


          • #6
            Hi,
            F1 'is' the form and yourfieldname stands for the actual field name.
            Let's say your field on the form is {username} the statement for disabling the field would be:

            document.F1.username.disabled = true; //notice the fieldname without brackets

            jsb

            Comment


            • #7
              Sorry guys but I must be missing something here.

              Created a button in a form called test, assigned the following JS code

              document.F1.titel.disabled = true;

              titel is the name of the field to disable.

              This was added automatically to toolbar.

              But clicking the button does nothing?!

              Comment


              • #8
                Well, I suppose you're talking about a control application and not a form application.
                If so, it's a little bit different.

                Change your code to: document.F1['titel'].disabled = true;

                jsb

                Comment

                Working...
                X