www.softwareriviera.com
Software Code
    New Code     Most Interesting     Don't Miss     Our picks  
JAVASCRIPT - section

View Article
Javascript Question Message
Javascript confirm function is similar to the alert function. The confirm box allows the user to choose, by either pressing OK to confirm the popup message or pressing cancel and not agreeing to the popup message request.
The code to generate a button asking a question is the following:
<input type ="button" value="Press Me!" onclick="return confirm('Do you understand now, how the confirm function works?');">

Press the button bellow to get the question generated by javascript "confirm" function:







Another way of using the confirm function is as follows

<html>
<head>
<script type="text/javascript">
<!--
function ask_for_confirmation() {
var get_answer = confirm("Question content comes here?")
if (answer){
alert("The question was answered afirmativelly (with Yes)!")
}
else{
alert("The question was NOT answered afirmativelly (with Cancel)!")
}
}
//-->
</script>
</head>
<body>
<input type="button" onclick="confirmation()" value="Press Me!">
</body>
</html>
Date: 2007-9-1    Written by: Admin A
     See all articles in this section
Copyright © 2007-2009 SoftwareRiviera.com. All rights reserved.  | Terms of use | Disclaimer | Privacy Policy |