Forum : prompt use in php
Brief description  about Online courses   join in Online courses
View sandeep kumar mahala 's Profile

prompt use in php

can anyone know how to use a prompt(javascript) in php code.
and get the input value to a php variable.
Asked by sandeep kumar mahala | Aug 16, 2010 |  Reply now
Replies (1)
View sanjay s nair 's Profile
<html><head>
<script type='text/javascript'>
function getName(){

name = (prompt('Enter your name'));
if(name != null)
{
document.getElementById('name').value = name;
document.test.submit();
}else{
alert('You have to enter your name');
}

}
</script>
</head>
<body>
<form name="test" action="" method="POST">
<input type="button" name="btn" value="Enter Name" onclick="getName()" />
<input type=hidden name="name" id="name" />
</form>

<?php
if(isset($_POST)){
$name = $_POST['name'];
echo "Your name is .. ".$name;
}
?>

</body>
</html>
Aug 17, 2010