PDA

View Full Version : Confirm box


Robert Bell
05-14-2003, 02:48 PM
Hi

The code below

var name = confirm("Are you sure?");

Displays a box with an Ok and a Cancel button.
Does anyone know of a way to display a box with a Yes and a No button?

Thanks,
Robert.

Mr J
05-14-2003, 03:31 PM
Probably the only way to have a confirm box with a "Yes" and "No" button is to create your own.


<SCRIPT language="JavaScript">
<!--
function showHide(layerid){
if (document.getElementById(layerid).style.visibility != "hidden"){
document.getElementById(layerid).style.visibility = "hidden";
}
else{
document.getElementById(layerid).style.visibility = "visible";
}
}

function yours(){
alert("This is where your function should be")
}

// -->
</SCRIPT>

<P align="center"><a class=lined href="#null" onclick="showHide('box2')"><b>Confirm Alert</b></a>

<DIV id="box2" style="position:absolute;left:350;top:150; width:250;color:#FFFFFF;border-top:2px solid #ffffff; border-left:2px solid #ffffff; border-right:2px solid #808080; border-bottom:2px solid #808080; background:#d8cfc8;visibility:hidden;text-align:center">

<div style="height:18;font-size:12;text-align:left;filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=1, StartColorStr='#FF005500', EndColorStr='#FF00ff00')">Your Site Name</div>

<P><center><font color="black" size=2>Is this what your really want?</font></center>

<form>
<span style="position:relative;left:0;top:0;width:75;height:22;border:1 groove #000000">
<input type=button value="Yes" style="width:74;height:20;font-size:10;border:1px outset #ffffff;" onclick="yours();showHide('box2')" >
</span>
<span style="position:relative;left:10;top:0;width:75;height:22;border:1 groove #000000">
<input type=button value="No" style="width:74;height:20;font-size:10;border:1px outset #ffffff;" onclick="showHide('box2')">
</span>
</form>
</DIV>

Robert Bell
05-14-2003, 03:38 PM
Thanks, that works a treat.

whackaxe
05-14-2003, 03:55 PM
or use vbscript to make the box and modify an object that both vbscript and jscript can acces like a <input hidden> tag. in theory that could work