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

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
Microsoft
Microsoft

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
Microsoft
Microsoft

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
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Users online (21,508)