web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Set web form fields dy...
Power Pages
Unanswered

Set web form fields dynamically to read only based on field value

(0) ShareShare
ReportReport
Posted on by 15

Hi all,

 

Can anyone give some guidance on how to set certain or all fields on a web form to read-only based on the value of a field (status).

 

So for example, when the status field contains the value 'closed' all fields should be set to read-only. When the status = 'open' all fields should be set to editable. When the status = 'awaiting input' some fields should be set to read-only.

 

I expect this can be done with custom Javascript code but do not know how. 

 

 

Categories:
I have the same question (0)
  • H V Profile Picture
    1,510 on at

    Hi @Edwin_VH 

     

    Can you please provide me screenshot of Status field and field which you want to make readonly?

  • Edwin_VH Profile Picture
    15 on at

    Thanks. I tried this but how to figure out the field_logicalname? Is that the ID or the Name tag of the field?

    I tried both but it's not working. 

     

  • H V Profile Picture
    1,510 on at

    Hi @Edwin_VH 

     

    Please add below code in Custom Javascript:

    • Go to your basic form
    • Click on Additional Settings tab
    • Add below code in Custom Javascript textbox
    $(document).ready(function() {
    	$("#statecode").change(function() {
    		var text = $("#statecode option:selected").text();
    		if(text == "closed")
    		{
    			$("#field_logicalname").attr('readonly')
    		}
    		else if (text == "awaiting input")
    		{
    			$("#field_logicalname").attr('readonly')
    		}
    		else{
    			//For remove readonly
    			//$("#location").removeAttr('readonly')
    		}
    	});
    })

     

    --------------------------
    If you like this post, give a Thumbs up. Where it solved your query, Mark as a Solution so it can help other people!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Pages

#1
Fubar Profile Picture

Fubar 55 Super User 2025 Season 2

#2
Lucas001 Profile Picture

Lucas001 25 Super User 2025 Season 2

#3
Jerald Felix Profile Picture

Jerald Felix 23

Last 30 days Overall leaderboard