<form name="email" method="post" action="forms/email.php">
<div id="email">
Sign up for Email
<input type="hidden" value="<?php $page; ?>" name="page">
<input class="searchtext" name="name" type="text" value="Name" id="nameId"/>
<input class="searchtext" name="email" type="text" value="Email" id="emailId"/>
<a id="submit" class="submitbutton" onClick="document.getElementById('search-form').submit()"></a>
</div>
</form>
<script type="text/javascript">
var name = document.getElementById("nameId");
name.addEventListener("click",func,false);
function func() {
alert(name.value)
}
</script>
I am trying to listen for the click of the the object but it gives me an object has no method error.
The problem seems to be that your variable named
namecollides withdocument.namethat´s undefined. Renaming the variable makes it work;Even this will work;