I'm calling a javascript function in php. it works when i call alert() method directly on click. here is my code
echo "<form action='' method='post' enctype='multipart/form-data' >
<div class='fileupload fileupload-new' style='width: 250px;' data-provides='fileupload'><input type='hidden' value='' name=''>
<div class='fileupload-preview thumbnail' style='width: 390px; height: 250px; '></div>
<div>
<span class='btn btn-file btn-success'><span class='fileupload-new'>Select image</span>
<span class='fileupload-exists'>Change</span><input type='file' name=''></span>
<button name='changepic' value='Save' class='btn btn-danger fileupload-exists' id='changeSitepic' onclick=\"alert('hi');\">Save</button>
</div>
</div>
</form>";
this is the line which causing problem. it works for direct alert() method
<button name='changepic' value='Save' class='btn btn-danger fileupload-exists' id='changeSitepic' onclick=\"alert('hi');\">Save</button>
but when i call it through other javascript function, then this won't work.
<button name='changepic' value='Save' class='btn btn-danger fileupload-exists' id='changeSitepic' onclick=\"changeSitepic();\">Save</button>
here is the javascript code.
<script type="text/javascript">
function changeSitepic(){
alert('hi');
}
</script>
I unable to find where i'm doing wrong. please help.
F12in a browser? How does it look there in source? Maybe are there any errors in log?