View Full Version : How can I display a confirm box with 3 buttons?
Coolvirus
07-31-2002, 08:15 PM
I need something like a confirm dialog box but in addition to the OK/Cancel buttons, I need a third button.
The intent is to do the following:
OK - Submits the form
Modify - Return to the form to modify it
Cancel - Send the user to a previous "data entry" screen
Is this possible?
Thank you in advance.
redhead
07-31-2002, 10:02 PM
well... unforunatly confirm boxes only come with two buttons, OK and Cancel, but surely "Modify" and "Cancel" would do the same thing... return the user to the form?
heres what i would do:
<script language="javascript" type="text/javascript">
function areYouSure(formName) {
continue=confirm('Are you sure?')
if (continue) {
document.formName.sumbit();
return false
}
else {
return false
}
};
</script>
<form name="theForm" onsubmit="areYouSure(this)" method="post" action="SomeAction.cgi">
<!-- all the rest of your form here -->
<input type="submit">
</form>
does this help?
happy coding :thumbsup:
Coolvirus
07-31-2002, 10:06 PM
In my case, the "Modify" and "Cancel" buttons do not do the same thing.
The "Modify" would act as a regular cancel where you return to the same form.
The "Cancel" in this case would do something different. It would re-direct the user to a previous page, a page different than the one they're in.
redhead
07-31-2002, 10:31 PM
hmm... sorry about that... failed to read your original question right... but heres a dHTML alternative...
in the <head> section:
<script>
function showConfirm(f){
if(f){visi="visible";}
else{visi="hidden";}
if(document.layers){
document.confirmit.visibility=visi;
}
if(document.all){
document.all.confirmit.style.visibility=visi;
}
if(document.getElementById){
document.getElementById("confirmit").style.visibility=visi;
}
}
function modify() {
showConfirm(0);}
function cancel() {
showConfirm(0);
history.back(1)}
</script>
adapt this for your form (<body> section):
<form action="someAction.cgi" method="post">
<!-- all your form fields here ......... -->
<input type="button" onclick="showConfirm(1)" value="Submit!">
<div style="position: absolute; left: 200; top: 200; visibility: hidden" id="confirmit">
<br>
<b>Are you sure?</b><br><br>
<input type="submit" value="OK"> <input type="button" value="Modify" onclick="modify()"> <input type="button" value="Cancel" onclick="cancel()">
</div>
</form>
hope this helps you,
happy coding :thumbsup:
redhead
07-31-2002, 10:32 PM
its that div id="confimit" which is the "fake" confirm box btw... :cool:
adios
08-01-2002, 01:19 AM
Not as cute but simpler:
<html>
<head>
<title>untitled</title>
<script type"text/javascript" language="javascript">
function mult_conf(f) {
if (confirm('OK: submit form\nCancel: edit current form/return to previous form')) return true;
if (confirm('OK: edit current form\nCancel: return to previous form')) return false;
else location = 'previous_page.htm';//could be history.go(-1)
}
</script>
</head>
<body>
<form onsubmit="return mult_conf(this)">
<input type="text" value="abcdefg">
<input type="submit">
</form>
</body>
</html>
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.