I have used confirm("")
popup alert function of javascript
in my jsp
page and it shows 'OK'
and 'Cancel'
button but i want 'YES' and 'NO'
instead.
Please tell me is there any way to do it or there is any alternative for it.
I have used confirm("")
popup alert function of javascript
in my jsp
page and it shows 'OK'
and 'Cancel'
button but i want 'YES' and 'NO'
instead.
Please tell me is there any way to do it or there is any alternative for it.
If you are using confirm statement in javascript you cant change it. you will have to create a custom confirmation box using java script or jquery. Here is an optional method without using jquery or javascript
<style type="text/css">
div#popup
{
position:absolute;
display:none;
top:200px;
left:50%;
width:500px;
margin-left:-250px;
border:1px solid blue;
padding:20px;
background-color:white;
}
</style>
<a
href="http://example.com/"
onClick="document.getElementById('popup').style.display = 'block'; return false;"
>Go to example.com</a>
<div id="popup">
<p>Are you sure you want to go to example.com?</p>
<p>
<a onclick="document.location='http://example.com/'; return false;">
Yes
</a>
<a onclick="document.getElementById('popup').style.display = 'none'; return false;">
No
</a>
</p>
</div>
Also you can use jquery
function askUserYesOrNo() {
var myDialog = $('<div class="mydialog"><p>Yes or No?</p><input type="button" id="yes" value="Yes"/><input type="button" id="no" value="No"/></div>');
$("#yes").click(handleYes);
$("#no").click(handleNo);
myDialog.modal(); //This would have to be replaced by whatever syntax the modal framework uses
}
function handleYes() {
//handle yes...
}
function handleNo() {
//handle no...
}
javascript limits the option for customizing confirm box. So you cannot change the Confirm box buttons from OK/Cancel
to YES/NO
You may use JQuery to customize that
Here is a link that uses JQuery and CSS3 for customized ConfirmBox
You can go for this Jquery base solution. It has option to add as many button you want and respective action to each.