I get the following error
uncaught typeerror : object is not a function
in the code below.
<html>
<head>
<title>Reverse</title>
</head>
<body>
<form name="rev1">
Enter the string : <input type="text" name="str">
<input type="button" value="click" onclick="rev1()" />
And this is the place where I found the error:
reverse of given string : <input type="text" name="res">
</form>
<script type="text/JavaScript">
function rev1(){
//var a=rev1.str.value;
//document.write("hello");
alert("hello");
}
</script>
</body>
</html>
What might cause this and how do I solve it?
Rename the form, or remove it altogether.
rev1references theformelement in your given script.Demos: Original – Working
(click in the button to call the function directly)
Edit: I’ve seen this matter raise many discussions, so I’ll leave some references as well: