TOPIC:

Turn the field read only by condition 1 week 4 days ago #250724

  • Topic Author
  • Luisserafim
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 98
  • Thanks: 0
Hi!

Is it possible to make the field read only with the value of another?

Something like this:

if element room is on set numberofrooms 1
if element room is on set numberofrooms 1 !readonly
if element room is off set numberofrooms !empty

Thanks in advance

Please Log in or Create an account to join the conversation.

Turn the field read only by condition 1 week 4 days ago #250730

  • Eddy.vh's Avatar
  • Eddy.vh
  • Offline
  • Gold Breezer
  • Gold Breezer
  • Posts: 475
  • Karma: 4
  • Thanks: 80
Hello,

Yes it is possible.

Two scenarios:
  1. The first element is a text element.
    In its advanced properties, action script, check "Custom", check "Change" and "create framwork code"

    After "change:" enter a script like this :
    if ( element.value == "on") {
                  
                  ff_getElementByName('elementName').readOnly = true;
                }
            else {
                 ff_getElementByName('elementName').readOnly = false;
                }
  2. The first element is a checkbox element.
    In its advanced properties, action script, check "Custom", check "clic" and "create framwork code"
    After "click:", enter a script like this :
    if ( element.checked) {
                  
                  ff_getElementByName('elementName').readOnly = true;
                }
            else {
                 ff_getElementByName('elementName').readOnly = false;
               }
PS: Change "elementName" with the real name (not title) of the element that is to become readonly.

Kind regards,
Eddy
The following user(s) said Thank You: Luisserafim

Please Log in or Create an account to join the conversation.

Last edit: Post by Eddy.vh.

Turn the field read only by condition 1 week 4 days ago #250738

  • Topic Author
  • Luisserafim
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 98
  • Thanks: 0
Hi Eddy!

The element is a list in a combobox. (Sorry for not informing)

I tried but it doesn't work.

Please help.

Best regards

Please Log in or Create an account to join the conversation.

Last edit: Post by Luisserafim.

Turn the field read only by condition 1 week 4 days ago #250741

  • Eddy.vh's Avatar
  • Eddy.vh
  • Offline
  • Gold Breezer
  • Gold Breezer
  • Posts: 475
  • Karma: 4
  • Thanks: 80
Hi,

What is a combobox?

Your Select list named "room" with options "on" or "off",
0;Make a selection;
0;Option 1;on
0;Option 2;off

In Advanced Properties of this Select list element, action script, custom, change, create framework.

After "change:", enter this script:
if( element.value == 'on') {
          ff_getElementByName('numberofrooms').value = 1;
          ff_getElementByName('numberofrooms').readOnly = true
        }
        else {
          ff_getElementByName('numberofrooms').value = "";
          ff_getElementByName('numberofrooms').readOnly = false;
        }

The entire script must look like this:
function ff_room_action(element, action)
{
    switch (action) {
        case 'change':
        
        if( element.value == 'on') {
          ff_getElementByName('numberofrooms').value = 1;
          ff_getElementByName('numberofrooms').readOnly = true
        }
        else {
          ff_getElementByName('numberofrooms').value = "";
          ff_getElementByName('numberofrooms').readOnly = false;
        }
            break;
        default:;
    } // switch
} // ff_room_action

Regards,
Eddy
The following user(s) said Thank You: Luisserafim

Please Log in or Create an account to join the conversation.

Last edit: Post by Eddy.vh.

Turn the field read only by condition 1 week 4 days ago #250748

  • Topic Author
  • Luisserafim
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 98
  • Thanks: 0
Its strange...

The field changes to "1" but readOnly doesn't work...

Thanxs in advance

Please Log in or Create an account to join the conversation.

Turn the field read only by condition 1 week 4 days ago #250750

  • Eddy.vh's Avatar
  • Eddy.vh
  • Offline
  • Gold Breezer
  • Gold Breezer
  • Posts: 475
  • Karma: 4
  • Thanks: 80
Ohhh, I forgot one; after "true" but even without it, the script works and does what it is supposed to do.

Please provide a link to your form so I can check.

Regards,
Eddy

Please Log in or Create an account to join the conversation.

Time to create page: 0.040 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!