我正在尝试遍历从“Info1”输入的值并显示范围 slider 。
例如:Info1 是 10,然后想添加 10 个范围 slider 。我收到此错误“Uncaught TypeError:info1 不是 HTMLInputElement.onkeyup 的函数”
谁能帮帮我。提前致谢。
<script type="text/javascript" charset="utf-8">
function info1()
{
var num1 = document.getElementById("info1").value;
if (num1 == '')
num1 = '0';
alert(num1);
}
</script>
<html>
<body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<?php $x=1; $num1 = 0;?>
<form method ="post" action ="info.php" >
<table>
<tr> <th> numeric A: </th>
<td> <input type="text" name="info1" id="info1" onkeyup="info1()" value=""> </td>
</tr>
<?php
while($x <= $num1) { ?>
<tr> <th> sliders</th>
<td><input type="Range" name="slider" min="0" max="1000" step="100" value="0"></input></td>
<?php $x++; } ?>
<tr> <td> </td>
<td> <input type ="submit" name="insert" value ="Add">
</td>
</tr>
</table>
</form>
</body>
</html>
最佳答案
一些浏览器获取元素的 id 并将它们放入全局变量中,因此您的函数 info1
被您的 info1 元素替换。更改函数的名称或元素的 ID。
关于javascript - 未捕获的类型错误 : info1 is not a function at HTMLInputElement. onkeyup,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49479768/