Click to See Complete Forum and Search --> : doubt in confirm dialog box


koel78
06-11-2003, 11:06 PM
if we give a message using the confirm dialog box ,it pops a window with ok and cancel button,is it possible to change the ok and canel button as yes or no instead?


can any one help.....


thanks and regards,
koel

Khalid Ali
06-11-2003, 11:14 PM
Not really...javascript is a limited scripting language,it does not let user make changes to system default settings.

koel78
06-11-2003, 11:23 PM
oh NOOOO...Anyway thanx for info.....


bye,
koel

requestcode
06-12-2003, 11:36 AM
Here is an example of how you can create a custom confirm box:
<html>
<head>
<title>Custom ConFirm, Alert and Prompt</title>
<style>
/* You can modify these styles to anything you want (or is allowed). */
/* These are used by both browsers. You can set these to your preferences. */
.td1style {font-weight:bold;border:1px solid black;background-color:lightgrey;color:blue;font-size:14px;fontFamily:Verdana;}
.td2style {font-weight:bold;border:1px solid black;background-color:lightyellow;font-size:12px;font-family:Verdana;}
/* the style below is for the links that are inside the div when it pops up */
.linkstyle {font-weight:bold;font-size:12px;text-decoration:none}
</style>
<script language="JavaScript">
var msgtop=50 // Set the top position of the div
var msgleft=20 // Set the left position of the div

/* The following three variables are for setting the properties of your table contained within the div. */
var tborder="0"
var cspace="0"
var cpad="0"
var tabheight=50 // Set the height of table
var tabwidth=150 // Set the width of table
var td1height=10
var td2height=30
var boxt=""
function Domsg(flag)
{
hidebox() // Hide the box after clicking on text link in box
if(flag=="Yes")
{
msg="You Clicked "+flag+"!"
}
else
{msg="Why did you click "+flag+"?"}
document.formbx.result.value=msg
}
function DoFormbox(msgtext)
{
theString="<table width='"+tabwidth+"' height='"+tabheight+"' border="+tborder+" cellspacing="+cspace+" cellpadding="+cpad+"><tr><td height='"+td1height+"' class='td1style' align='left'><b>"
theString+=""+msgtext+"</b></td></tr><tr><td height='"+td2height+"' align='center' class='td2style'><a href='javascript:Domsg(\"Yes\")' class='linkstyle'>Yes</a>&nbsp &nbsp<a href='javascript:Domsg(\"No\")' class='linkstyle'>No</a></td></tr></table>"
if (document.layers) // Netscape 4.0+
{
document.formbox.document.write(theString)
document.formbox.document.close()
document.formbox.left=msgleft
document.formbox.top=msgtop+40
document.formbox.visibility="show"
}
else
{
if(document.getElementById) // Internet Explorer 5.0+ and Netscape 6.0+
{
elm=document.getElementById("formbox")
elm.innerHTML=theString
elm.style.top=msgtop
elm.style.left=msgleft
elm.style.visibility = "visible"
}
}
}

// This function is for hiding the div
function hidebox()
{
if (document.layers) // Netscape 4.0+
{
document.formbox.visibility="hidden"
}
if(document.getElementById) // Netscape 6.0+ and Internet Explorer 5.0+
{
elm.style.visibility="hidden"
}
}
</script>
</head>
<body>
<div id="formbox" style="position:absolute;visibility:hidden;left:0;top:0;"></div>
<center>
<h1>Custom Confirm</h1>
<form name="formbx">
<input type="text" name="result" size="30">
</form>
<a href="javascript:DoFormbox('Are you sure?')">Click Me for a Confirm Box</a><br>
</center>
</body>
</html>