This question already has an answer here:
Trying out PHP for the first time and I'm really stumped on this. It might be something obvious, but why isn't my php inside the function checkinfo() working? The alert works fine. Here's the code
<head>
<script type="text/javascript">
function checkinfo() {
alert("hi");
<?php
echo 'hi';
?>
};
</script>
</head>
<body>
<form id = "form" align = "center">
<div id = "index">
<div id = "unandpw">
Username:
<input type="text">
<br>
Password:
<input type ="password" >
</div>
<!-- end unandpw -->
<div id = "buttons">
<button type = "button" onclick = "checkinfo()">
Login
</button>
<button type = "button" onclick = "register();">
Register
</button>
</div>
<!-- end buttons -->
</div>
<!--index end -->
</form>
</body>
</html>
'hi'
means nothing in JavaScript... What are you expecting? – elclanrs Aug 17 '13 at 8:14echo
merely prints text that will be interpreted by JavaScript later. – elclanrs Aug 17 '13 at 8:22