...

View Full Version : Problem with Confirm box



swethak
07-29-2009, 01:34 PM
Hi,


I want to applying the styles for confirm box. For this purpose i have used below code.

Here i am writting my code


<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>untitled</title>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
<script type="text/javascript">
function doConfirm(v)
{
var b = document.getElementById('btn');
b.value = 'Display dialog [last return value: ' + v + '/' + (v ? 'OK' : 'Cancel') + ']';
}

function setDisp(id, disp, some)
{
document.getElementById(id).style.display = disp;
return some;
}
</script>
<style type="text/css">
#confirm {
position: absolute;
top: 40px;
left: 70px;
border: outset #000 10px;
padding: 1em 3em;
display: none;
background: #a5c4cc;
}

#ok {
background: #a5cca8;
}

#cancel {
background: #d6a4a4;
}

#ok, #cancel {
padding: 2px;
margin:2px;
}
</style>
</head>
<body>
<div id="confirm">
<div><strong>Are</strong> <em>you</em> <span style="text-decoration: underline;">sure</span>?</div>
<input type="button" id="ok" value="OK" onClick="setDisp('confirm', 'none','yes');" />
<input type="button" id="cancel" value="Cancel" onClick="setDisp('confirm', 'none','no');" />
</div>
<input type="button" id="btn" value="Display dialog" onClick="setDisp('confirm', 'block','');" />
</body>
</html>




In above code i have to set return value to the function setDisp() as true/false when click on ok ,cancel buttons. That means when i used the function setDisp() directly then it displayed the pop up window consists the ok,Cancel buttons.When i click on ok this function setDisp() returns true and when click on cancel this function setDisp() returns false. That is my requirement .Any body could you please help me how can get the Requirement.



Thanks
Swetha

Philip M
07-29-2009, 02:51 PM
Well, just change yes and no to true and false.

<input type="button" id="ok" value="OK" onClick="setDisp('confirm', 'none','true');" />
<input type="button" id="cancel" value="Cancel" onClick="setDisp('confirm', 'none','false');" />



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum