This code is working fine outside wordpress but Wordpress shows follwing error and does nothing. Can anyone tell the reason? Thanks
Uncaught SyntaxError: Unexpected token ILLEGAL custom_params.js:2Uncaught TypeError: Object # has no method 'prettyPhoto' chrome-extension://mpcddcfoblbgmnaklcpkbfajnfikinhn/videodownload.js:5Uncaught TypeError: Cannot read property '0' of null 3/wordpress/?page_id=458:169Uncaught ReferenceError: addInput is not defined
<script type="text/javascript">
var counter = 1;
var limit = 3;
function addInput(divName){
if (counter == limit) {
alert("You have reached the limit of adding " + counter + " inputs");
}
else {
var newdiv = document.createElement('div');
newdiv.innerHTML = "Entry " + (counter + 1) + " <br><input type='text' name='myInputs[]'>";
document.getElementById(divName).appendChild(newdiv);
counter++;
}
}
</script>
<form method="POST">
<div id="dynamicInput">
Entry 1<br><input type='text' name='myInputs[]'>
</div>
<input type='button' value='Add another text input' onClick='addInput("dynamicInput")'>
</form>