<script type="text/javascript">
function accept(s)
{
alert(s);
}
</script>
<input type="button" style="background-color:#e2e6f0;border:1px solid
#DCDCDC;padding-left:5px;padding-right:5px;padding-top:3px;padding-bottom:3px"
value="accept" onclick="accept('28391135292739653997')">
Why the onclick event not triggering the accept function? I was expecting it to work. I thought it might be due to number of digits but it worked in my sample where I used 30 digits too. Where is my mistake?
It's because accept is the name of a property of the input element. So the onclick event is trying to call the accept property as a method, rather than the accept function you've defined. If you change it to:
onclick="window.accept('28391135292739653997')"
It will call the globally defined accept function.
It seems to work if you call it something other than accept:
http://jsfiddle.net/Bt5Q3/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With