Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-31-2002, 08:15 PM   PM User | #1
Coolvirus
New Coder

 
Join Date: Jul 2002
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Coolvirus is an unknown quantity at this point
How can I display a confirm box with 3 buttons?

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.

Last edited by Coolvirus; 07-31-2002 at 10:03 PM..
Coolvirus is offline   Reply With Quote
Old 07-31-2002, 10:02 PM   PM User | #2
redhead
Regular Coder

 
Join Date: Jun 2002
Location: United Kingdom Confused: Often
Posts: 859
Thanks: 0
Thanked 0 Times in 0 Posts
redhead is an unknown quantity at this point
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
__________________
redhead
redhead is offline   Reply With Quote
Old 07-31-2002, 10:06 PM   PM User | #3
Coolvirus
New Coder

 
Join Date: Jul 2002
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Coolvirus is an unknown quantity at this point
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.
Coolvirus is offline   Reply With Quote
Old 07-31-2002, 10:31 PM   PM User | #4
redhead
Regular Coder

 
Join Date: Jun 2002
Location: United Kingdom Confused: Often
Posts: 859
Thanks: 0
Thanked 0 Times in 0 Posts
redhead is an unknown quantity at this point
whoops...

hmm... sorry about that... failed to read your original question right... but heres a dHTML alternative...

in the <head> section:
Code:
<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):
Code:
<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">&nbsp;<input type="button" value="Modify" onclick="modify()">&nbsp<input type="button" value="Cancel" onclick="cancel()">
</div>

</form>
hope this helps you,

happy coding
__________________
redhead
redhead is offline   Reply With Quote
Old 07-31-2002, 10:32 PM   PM User | #5
redhead
Regular Coder

 
Join Date: Jun 2002
Location: United Kingdom Confused: Often
Posts: 859
Thanks: 0
Thanked 0 Times in 0 Posts
redhead is an unknown quantity at this point
its that div id="confimit" which is the "fake" confirm box btw...
__________________
redhead
redhead is offline   Reply With Quote
Old 08-01-2002, 01:19 AM   PM User | #6
adios
Senior Coder

 
Join Date: Jun 2002
Posts: 1,404
Thanks: 2
Thanked 32 Times in 32 Posts
adios is on a distinguished road
Not as cute but simpler:
Code:
<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>
adios is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:20 AM.


Advertisement
Log in to turn off these ads.