How can I make a checkbox in the view return data from the controller when checked and display it in input boxes?
<input class="js-recipient-is-me" type="checkbox"/>
Javascript :
$('.js-recipient-is-me').change(function () {
if (this.checked) {
$('.js-input-field').addClass('disabled');
$.ajax({
url: '/Cart/GetUserInfo',
});
} else {
$('.js-input-field').removeClass('disabled');
}
});
Html Inputs :
<input type="text" id="mobile" class="js-input-field" name="name" />
<input type="text" id="name" class="js-input-field" name="name" />
<input type="text" id="family" class="js-input-field" name="name" />
Controller :
public async Task<JsonResult> GetUserInfo()
{
CurrentUserId = User.FindFirstValue(ClaimTypes.NameIdentifier);
var userinfo = await _scope.GetUserInfo(Guid.Parse(CurrentUserId));
return Json(0);
}
userinfo
is a string array with three values:
["Mobile", "name", "family"]
I want to populate the input fields with the values from userinfo
...
Any suggestions on how to achieve this?