Tuesday, July 10, 2012

Javascript in html for dummies part 1


1. Pop up warn message for confrim box
here's the code

<!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 type="text/javascript">
function myFunction()
{
var x;
var r=confirm("Submit?");
if (r==true)
  {
  x="You pressed OK!";
  }
else
  {
  x="You pressed Cancel!";
  }
document.getElementById("demo").innerHTML=x;
}
</script>

</body>
</html>



Click the button to display a confirm box.



2. 

No comments:

Post a Comment