Fields disabled onReady() magically re-enable

In my onReady() function, I have disabled some text input fields on my form based on whether certain values are set in dataset. This works fine. However, when one of the other form fields is set, a dropdown or a radio button, the rest of the fields re-enable for some reason. I want them to remain disabled.
How do I do this?

1 Like

Hi Paul,

Please show how you are doing this.

Yisrael

I am having a similar issue Yisrael on my site: https://taylorje3000.wixsite.com/letterman-jackets. If I click the checkbox, the input fields that should hide do disappear. However, when I either try to submit without selecting a dropdown item or click on the dropdown menu, the other input fields are somehow re-enabled. I tried putting the disable code for the input fields in onReady, but that didn’t fix it. Please note that the input is linked to a dataset, and validation is performed on the input. The affected input fields are #bodyColorChoice, #secondColorChoice, #knitColorChoice, and #materialChoice. Here is my script:

// For full API documentation, including code examples, visit Velo API Reference - Wix.com

$w.onReady(function () {
//TODO: write your page related code here…

});

export function useSchoolDesign_change(event, $w) {
//Add your code for this event here:
let isChecked = $w(β€œ#useSchoolDesign”).checked; // true
if (isChecked) {
$w(β€œ#schoolDesignChoice”).show();
$w(β€œ#schoolDesignChoice”).enable();
$w(β€œ#school”).show();
$w(β€œ#bodyColorChoice”).disable();
$w(β€œ#secondColorChoice”).disable();
$w(β€œ#knitColorChoice”).disable();
$w(β€œ#materialChoice”).disable();
$w(β€œ#schoolDesignChoice”).required = true;
$w(β€œ#bodyColorChoice”).required = false;
$w(β€œ#secondColorChoice”).required = false;
$w(β€œ#knitColorChoice”).required = false;
$w(β€œ#materialChoice”).required = false;
} else {
$w(β€œ#schoolDesignChoice”).hide();
$w(β€œ#schoolDesignChoice”).disable();
$w(β€œ#school”).hide();
$w(β€œ#bodyColorChoice”).enable();
$w(β€œ#secondColorChoice”).enable();
$w(β€œ#knitColorChoice”).enable();
$w(β€œ#materialChoice”).enable();
$w(β€œ#schoolDesignChoice”).required = false;
$w(β€œ#bodyColorChoice”).required = true;
$w(β€œ#secondColorChoice”).required = true;
$w(β€œ#knitColorChoice”).required = true;
$w(β€œ#materialChoice”).required = true;
}

}

export function schoolDesignChoice_change(event, $w) {
//Add your code for this event here:
$w(β€œ#bodyColorChoice”).disable();
$w(β€œ#secondColorChoice”).disable();
$w(β€œ#knitColorChoice”).disable();
$w(β€œ#materialChoice”).disable();
}

export function submitbutton_click(event, $w) {
//Add your code for this event here:
let isChecked = $w(β€œ#useSchoolDesign”).checked; // true
if (isChecked) {
$w(β€œ#bodyColorChoice”).required = false;
$w(β€œ#secondColorChoice”).required = false;
$w(β€œ#knitColorChoice”).required = false;
$w(β€œ#materialChoice”).required = false;
$w(β€œ#bodyColorChoice”).disable();
$w(β€œ#secondColorChoice”).disable();
$w(β€œ#knitColorChoice”).disable();
$w(β€œ#materialChoice”).disable();
}
}

Hi Jeremy,

Do you still experience this issue?
If so, please specify the mode your dataset is configured to (either read, write or read/write)

Thx

1 Like

Hello Ido

I had a multistage form working just fine for months. Then without any changes to the site or code the input fields on slide 2 of the form are disabled. There’s been no change to the code or the site. The input fields on slide 1 and slide 3 work fine but slide 2 suddenly stopped working. Fields are disabled.
Have you encountered this problem or have any ideas?
Please help if you can
Thanks

Hi Bidfix,

Can you paste your editor url here?

Is there any fix to this issue?!? I do have the same problem on my side.
Depending on the user selection of a radioButtonGroup I enable or disable a specific field.
$w( β€œ#radioGroup1” ).onChange((event) => {
const selectedOption = event.target.value;
console.log( "changed to option: " + selectedOption);
const options = $w( β€œ#radioGroup1” ).options;
if (selectedOption == options[ 0 ].label) {
createUnique();
} else {
createDuplicate();
}
});

const createDuplicate = () => {
$w( β€œ#vectorImage11” ).scrollTo();
$w( β€œ#dropdown1” ).disable().then(() => {
console.log( "dropdown is enabled: " + $w( β€œ#dropdown1” ).enabled);
$w( β€œ#dropdown1” ).disable();
console.log( "dropdown is enabled: " + $w( β€œ#dropdown1” ).enabled);
}). catch (() => {
console.log( β€œerror while disabling dropdown” );
});
console.log( "radioButtons are enabled: " + $w( β€œ#radioGroup2” ).enabled);
$w( β€œ#radioGroup2” ).disable();
console.log( "radioButtons are enabled: " + $w( β€œ#radioGroup2” ).enabled);
$w( β€œ#input1” ).disable();
$w( β€œ#text42” ).hide();
$w( β€œ#text44” ).show();
$w( β€œ#radioGroup2” ).required = false ;
$w( β€œ#dropdown1” ).required = false ;
};

And this is the console output after changing the option in the radioButtonGroup on my side:
changed to option: create duplicate

radioButtons are enabled: true

radioButtons are enabled: false

dropdown is enabled: true

dropdown is enabled: false

The dropdown is sucessfully disabled on my side. But this only after disabling it twice! The radioButtonGroup should be disabled according to the console output, but on my published website the group is still clickable. After clicking on the radioButtonGroup the dropdown I set to disabled before is enabled again.
There is no difference between preview mode and published website.
My database is configured to write.

I really need a fix for it!! Please help me and tell me what I am doing wrong.

Thans in advance.