In this article we will discuss to to demonstrate a prompt box in javascript. When the user click’s the button event will be raise it calls the javascript function there we have implement prompt box.
Example:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>demonstrate theprompt box</title>
</head>
<body>
<p>Click the button to demonstratethe prompt box.</p>
<button onclick="myFunction()">Try it</button>
<p id="message"></p>
<script type="text/javascript">
function myFunction() {
var person = prompt("Please enter your name", "shahrukh khan");
if (person != null) {
document.getElementById("message").innerHTML=
"Hello " + person + "! How are you today?";
}
}
</script>
</body>
</html>
Output:
Post your comments / questions
Recent Article
- How to get domain name information from a Domain using Python
- ModulenotFoundError: no module named 'debug_toolbar' -SOLUTION
- How to create superuser in django project hosted in cPanel without terminal
- CSS & images not loading in django admin | cpanel without terminal
- Could not build wheels for mysqlclient, which is required to install pyproject.toml-based projects
- How to sell domain name on Godaddy (2023)
- TemplateSyntaxError at / Could not parse the remainder: ' + 1' from 'forloop.counter0 + 1'
- urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'OpenSSL 1.0
Related Article