Uncaught TypeError: info1 is not a function at HTMLInputElement.onkeyup

时间:2018-03-25 19:02:55

标签: javascript php html

I am trying to loop through the value entered from 'Info1" and displaying range sliders.

Ex: Info1 is 10, then would like to add 10 range sliders. I get this error "Uncaught TypeError: info1 is not a function at HTMLInputElement.onkeyup"

Could anyone help me. Thanks in Advance.

<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>

1 个答案:

答案 0 :(得分:1)

Some browsers take the ids of elements and make them into global variables, so your function info1 is replaced by your info1 element. Change either the name of the function or the id of the element.