cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Solution Supplier
Solution Supplier

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

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
Highlighted
Solution Supplier
Solution Supplier

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

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!

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

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Users online (7,248)