I have a php file. I am trying to run Javascript code inside it. My code is:
<form id = "form" action= "form.php" method = "post">
Name: <input type = "text" id = "FirstName" name="name"/>
<input type="submit" id="click" value ="Enter name"/>
</form>
<?php
$name = $_POST['name'];
if ($name == "sam"){
echo "
<script type = 'text/javascript'>
var a = document.getElementbyId('name');
alert(a);
</script>
";
}
else {
echo "Wrong name";
}
?>
However javascript does not work. Any idea why my script is not running?