How can I add a simple dialogue box in my webpage using html code? Tell the coding for the dialogue box and how to edit the data in the dialogue box?
Answers
Answered by
0
Basically, dialogue boxes are added using Javascript code.
Like this
<!DOCTYPE html><html><body>
<p>Click the button to display a confirm box.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>function myFunction() { var x; if (confirm("Press a button!") == true) { x = "You pressed OK!"; } else { x = "You pressed Cancel!"; } document.getElementById("demo").innerHTML = x;}</script>
</body></html>
Here I used the latest version of HTML i.e. HTML5 which is marked by the tag <!doctype html>.
Like this
<!DOCTYPE html><html><body>
<p>Click the button to display a confirm box.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>function myFunction() { var x; if (confirm("Press a button!") == true) { x = "You pressed OK!"; } else { x = "You pressed Cancel!"; } document.getElementById("demo").innerHTML = x;}</script>
</body></html>
Here I used the latest version of HTML i.e. HTML5 which is marked by the tag <!doctype html>.
Similar questions