javascript - 如何以编程方式创建输入/输出系统?
问题描述
基本上,我想设计一个具有签入/签出功能的表格,用户可以在其中按下按钮并签入或签出,具体取决于他们之前的状态。我在 Visual Studios 中创建了 webform.aspx。
<title> Check-in Board </title>
<link href="StyleSheet.css" type="text/css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
</head>
<body>
<img src="logo.png" class="center" />
<form id="form1" runat="server">
<%--<asp:Panel ID="toggleSwitch" runat="server">--%>
<table id="board">
<tr>
<th> In </th>
<th> Out </th>
</tr>
<tr id="row">
<td>
firstName lastName <button type="button" class="myBtn" onclick="myFunction()"> Out </button>
</td>
<script>
function myFunction() {
var x = document.getElementById("myBtn");
//x.disabled = true;
alert("You have signed out.");
//remove cell with person name under in column
$("#board").on('click', '.myBtn', function () {
$(this).closest('td').remove();
//create new cell
var row = document.getElementById("row");
var x = row.insertCell(-1);
x.innerHTML = "firstName lastName";
//create new button in new cell
var btn = document.createElement("BUTTON");
btn.innerHTML = "In";
document.body.appendChild(btn);
//click button to move to In column
btn.onclick = function () {
alert("You have signed in.");
var row = document.getElementById("row");
var y = row.insertCell(0);
var z = row.deleteCell(-1);
y.innerHTML = "firstName lastName";
}
});
}
</script>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
</table>
<%--</asp:Panel>--%>
</form>
</body>
</html>
如果这个人是“in”,那么“in”列会显示他们的名字和一个写着“out”的按钮,一旦按下,就会将他们移到“out”列,并带有一个新的按钮,上面写着“ in”,反之亦然。我想我的第一部分是正确的,名称显示在带有“out”按钮的“in”列中,单击时将它们切换到 out 列。当我尝试按下“out column”中的“in”按钮(将它们签入)时,就会出现问题;它将它们带回“in”列,但没有按钮。我需要做什么来解决这个问题?我需要有一个循环吗?
解决方案
推荐阅读
- php - 如何将字符串中的数组路径评估为真实的数组路径
- c# - C#将两个标题列合并为一列?
- python-3.x - Numpy 和 TensorFlow RNN 形状表示不匹配
- docker - 为什么 docker 节点容器在 docker 卷中找不到本地文件?
- kubernetes-ingress - 将特定子目录重定向到 Ingress 中的新 url
- java - 即使我只添加到它,我是否应该使列表线程安全?
- java - Apache Flink 与 AWS Kinesis Analytics
- laravel - 如何在 Laravel 5.7 中生成 JWT 刷新令牌
- python - SyntaxError:无效的语法 Selenium
- c++ - 第一次在 NetBeans IDE 8.2 中使用 SFML-2.5.1 我遇到了问题