[英]ASP.Net core, How to log users information when a check box is checked?
我一直在努力寻找有关如何记录用户信息的信息,例如当选中复选框时(例如,该信息应在用户不知情的情况下记录)。 这是我的代码:
这是MDB设计的“开关”复选框
<div>
<div class="switch">
<label>
Checked and Verified
<input type="checkbox" checked>
<span class="lever"></span>
</label>
</div>
当“ leaver”(复选框)设为true时,我希望记录以下内容:
<input id="username" value="@User.Identity.Name" />
@Html.EditorFor(x => x.DateCreated)
但是,我找不到@if语句或任何有效的javascript代码。 请帮我 :(
使用JavaScript:
<input type="checkbox" id="myCheck" onclick="myFunction()" checked>
您可以在JS中建立逻辑:
function myFunction() {
// Get the checkbox
var checkBox = document.getElementById("myCheck");
// If the checkbox is checked, display the output text
if (checkBox.checked == true){
//log
} else {
//do not log
}
}
像这里描述的链接
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.