Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jul 2002
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    United Kingdom Confused: Often
    Posts
    859
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #3
    New Coder
    Join Date
    Jul 2002
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    United Kingdom Confused: Often
    Posts
    859
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    United Kingdom Confused: Often
    Posts
    859
    Thanks
    0
    Thanked 0 Times in 0 Posts
    its that div id="confimit" which is the "fake" confirm box btw...
    redhead

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Posts
    1,404
    Thanks
    2
    Thanked 32 Times in 32 Posts
    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>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •