cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

Enable a field upon another field's value

Hey, I was including an entity form here to my web form as additional action and I wanted to disable the field Other University and only enable it when the field Institute Name is set as "Others...". Is there any possible way to add the custom javascript to the entity form to achieve that? Thank you in advance!

byansakura_0-1600406930422.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Solution Supplier
Solution Supplier

Re: Enable a field upon another field's value

Hi @byansakura,

In your Entity Form's custom JS, use the below code - update for your actual field schemas.

If you want to clear & hide the value for any selection other than "Other..."

$(function () {
    var $instName = $("#new_institutename);
    $instName.change(function () {
        if ($instName.val() === "1234567") { // use actual option set value for 'Other...'
            $("#new_otheruniversity").closest("td").show();
        } else {
            $("#new_otheruniversity").val("").closest("td").hide();
        }
    }).change();
});

If you want to instead disable it:

$(function () {
    var $instName = $("#new_institutename);
    $instName.change(function () {
        if ($instName.val() === "1234567") { // use actual option set value for 'Other...'
            $("#new_otheruniversity").prop("readonly", false);
        } else {
            $("#new_otheruniversity").val("").prop("readonly", true);
        }
    }).change();
});

 If you don't want to clear the value, you can leave off the .val("") part and just use .prop("readonly", true");

View solution in original post

2 REPLIES 2
Highlighted
Solution Supplier
Solution Supplier

Re: Enable a field upon another field's value

Hi @byansakura,

In your Entity Form's custom JS, use the below code - update for your actual field schemas.

If you want to clear & hide the value for any selection other than "Other..."

$(function () {
    var $instName = $("#new_institutename);
    $instName.change(function () {
        if ($instName.val() === "1234567") { // use actual option set value for 'Other...'
            $("#new_otheruniversity").closest("td").show();
        } else {
            $("#new_otheruniversity").val("").closest("td").hide();
        }
    }).change();
});

If you want to instead disable it:

$(function () {
    var $instName = $("#new_institutename);
    $instName.change(function () {
        if ($instName.val() === "1234567") { // use actual option set value for 'Other...'
            $("#new_otheruniversity").prop("readonly", false);
        } else {
            $("#new_otheruniversity").val("").prop("readonly", true);
        }
    }).change();
});

 If you don't want to clear the value, you can leave off the .val("") part and just use .prop("readonly", true");

View solution in original post

Highlighted
Helper III
Helper III

Re: Enable a field upon another field's value

Thank you so much @justinburch , it works!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Users online (6,687)