Skip to content
Advertisement

set a value of checkbox while loading data from database using ajax

I’m using asp core and ajax to load a data table. When I got the data from the database and the value of isAnswerRequired=true, so the checkbox should be ‘checked’, I used the ‘question mark conditional’ to change the value, but nothing happened.

Please assist me in resolving the problem, I want the checkbox to be checked when the isAnswerRequired=true.

DataSharing.cshtml:

JavaScript

DataSharingInfo.js:

JavaScript

Advertisement

Answer

My code below worked for me, when I set the data as true the input checkbox will be checked.

enter image description here

JavaScript

or using ajax configuration:

my api:

JavaScript

ajax setting:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement