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

Announcements

News and Announcements icon
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 

     

    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!

  • 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 

     

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

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Pages

#1
Fubar Profile Picture

Fubar 26 Super User 2026 Season 1

#2
Lucas001 Profile Picture

Lucas001 19 Super User 2026 Season 1

#3
CN-06091549-0 Profile Picture

CN-06091549-0 18

Last 30 days Overall leaderboard