cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Set default value in input text box and disable doesn't capture the value when saved

Hi,

 

When trying to create a record using entity form, I  preset the input text box with a default value and disable it so that user cannot change the value. However when the user submits the form, the value is not stored in the database. 

If I didn't disable the text box, it's working fine. Is there any way to resolve this?

 

Here is the code that I used to set the default value in the text box (id = pid_material)

$("#pid_material").val("Aluminium"); 
 
I also tried with this one but same result:
$("#pid_material").attr("value", "Aluminium");
 
And here is the code that I use to disable the input text box
$( "#pid_material" ).prop( "disabled", true );
 
Any helps would be appreciated.
 

Thanks,

Harry

 

1 ACCEPTED SOLUTION

Accepted Solutions
Solution Supplier
Solution Supplier

Interesting find here, @harry_c2020 - I didn't know this worked this way. I assume it's because some aspect of portal config uses the disabled property and they want to ensure it can't be broken by simple console JS.

Regardless, I found that I was able to make it work by switching from disabled to readonly properties.

 

$("#pid_material").prop("readonly", true);

 

View solution in original post

1 REPLY 1
Solution Supplier
Solution Supplier

Interesting find here, @harry_c2020 - I didn't know this worked this way. I assume it's because some aspect of portal config uses the disabled property and they want to ensure it can't be broken by simple console JS.

Regardless, I found that I was able to make it work by switching from disabled to readonly properties.

 

$("#pid_material").prop("readonly", true);

 

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Users online (13,561)