我想实现当在输入框里输入“1”时就会弹出一个表格输入框 用javascript实现
1个回答
展开全部
<html>
<script>
function checkUserInput(value) {
if (value == "1")
{
document.getElementById("overLay").style.display = "block";
document.getElementById("userInputDiv").style.display = "block";
}
}
function cancelInput() {
document.getElementById("overLay").style.display = "none";
document.getElementById("userInputDiv").style.display = "none";
}
</script>
<body style="margin:0px;padding:0px;">
<div>
<input type="text" onkeyup="checkUserInput(this.value)">
</div>
<div id="userInputDiv" style="width:520px;height:308px;position:absolute;top:20%;left:25%;border:1px solid #393939;background:white;display:none;z-index:900;">
<table border="1">
<tr>
<td><input type="text"></td><td><input type="text"></td><td><input type="text"></td>
</tr>
<tr>
<td><input type="text"></td><td><input type="text"></td><td><input type="button" value="OK" onclick="cancelInput()"><input type="button" value="Cancel" onclick="cancelInput()"></td>
</tr>
</table>
</div>
<div id="overLay" style="position:absolute;top:0px;left:0px;width:100%;height:100%;z-index:2;background:#999999;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=60);opacity:0.6;display:none;cursor:not-allowed;"></div>
</body>
</html>
<script>
function checkUserInput(value) {
if (value == "1")
{
document.getElementById("overLay").style.display = "block";
document.getElementById("userInputDiv").style.display = "block";
}
}
function cancelInput() {
document.getElementById("overLay").style.display = "none";
document.getElementById("userInputDiv").style.display = "none";
}
</script>
<body style="margin:0px;padding:0px;">
<div>
<input type="text" onkeyup="checkUserInput(this.value)">
</div>
<div id="userInputDiv" style="width:520px;height:308px;position:absolute;top:20%;left:25%;border:1px solid #393939;background:white;display:none;z-index:900;">
<table border="1">
<tr>
<td><input type="text"></td><td><input type="text"></td><td><input type="text"></td>
</tr>
<tr>
<td><input type="text"></td><td><input type="text"></td><td><input type="button" value="OK" onclick="cancelInput()"><input type="button" value="Cancel" onclick="cancelInput()"></td>
</tr>
</table>
</div>
<div id="overLay" style="position:absolute;top:0px;left:0px;width:100%;height:100%;z-index:2;background:#999999;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=60);opacity:0.6;display:none;cursor:not-allowed;"></div>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询