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 8 of 8
  1. #1
    Regular Coder hinch's Avatar
    Join Date
    Sep 2005
    Location
    UK
    Posts
    923
    Thanks
    25
    Thanked 80 Times in 80 Posts

    Confirmation button on submit

    I'm a little confused here

    I've got a little javascript function for popping up a simple alert box on a link click what I want to do though is to change it from a link to a button in a form.

    I've tried making it a <form onSubmit=""> and also tried putting it in the submit onClick it works fine if i have it on a normal href as an onClick just not in the form/button combination what/where am i going wrong

    Javascript
    Code:
    // confirm unassign
    function confirmunassign(){
        msg = "You are about to unassign this lead are you sure you wish to do this";
        return confirm(msg);
    }
    Form
    Code:
    <form id="editform" name="editform" action="dashboard.php?LoadModule=leads&action=edit&cid=<?php echo $_GET['cid'];?>&Subs=<?php echo $_GET['Subs']?>" method="post">
    			<input class="button" type="submit" name="actionbutton" id="actionbutton" value="Edit" onClick="return confirmunassign()" />
    </form>
    Basically if they click no/cancel it needs to not do the submit or if they click ok then it does the submit.

    Any help would be much appreciated
    A programmer is just a tool which converts caffeine into code

    My work: http://www.fcsoftware.co.uk && http://www.firstcontactcrm.com
    My hobby: http://www.angel-computers.co.uk
    My life: http://www.furious-angels.com

  • #2
    Regular Coder
    Join Date
    Nov 2007
    Location
    Leeds, UK
    Posts
    514
    Thanks
    24
    Thanked 19 Times in 19 Posts
    What are you trying to do
    Are you trying to bring up a pop up box when they submit some thing to confirm the submit

    If so use window.open() on a button not a submit
    Code:
    <input type="button" value="Continue" onClick="window.open('bla','bla','bla');" />
    Then use the parent.document.getElementById("FORM ID").submit(); on a button in your pop up

    And the Cancel just closed the window window.colse(); i think

    Do not hold my script up to work im still learning but i think that is how you do it if not im sure some one will correct me
    Last edited by barkermn01; 08-07-2008 at 03:49 PM.

  • #3
    Regular Coder hinch's Avatar
    Join Date
    Sep 2005
    Location
    UK
    Posts
    923
    Thanks
    25
    Thanked 80 Times in 80 Posts
    not trying to open a popup thats easy i'm trying to use the alert box
    it pops up like this when put on a normal href now i'm just trying to get it to do the same on a submit button

    A programmer is just a tool which converts caffeine into code

    My work: http://www.fcsoftware.co.uk && http://www.firstcontactcrm.com
    My hobby: http://www.angel-computers.co.uk
    My life: http://www.furious-angels.com

  • #4
    Regular Coder
    Join Date
    Nov 2007
    Location
    Leeds, UK
    Posts
    514
    Thanks
    24
    Thanked 19 Times in 19 Posts
    oo the system box
    one min

  • #5
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,855
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Code:
    <script type="text/javascript">
    // confirm unassign
    function confirmunassign(){
        msg = "You are about to unassign this lead are you sure you wish to do this";
        return confirm(msg);
    }
    </script>
    Code:
    <form id="editform" name="editform" onsubmit="return confirmunassign();" action="dashboard.php?LoadModule=leads&action=edit&cid=<?php echo $_GET['cid'];?>&Subs=<?php echo $_GET['Subs']?>" method="post">
    			<input class="button" type="submit" name="actionbutton" id="actionbutton" value="Edit"  />
    </form>
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    hinch (08-07-2008)

  • #6
    Regular Coder hinch's Avatar
    Join Date
    Sep 2005
    Location
    UK
    Posts
    923
    Thanks
    25
    Thanked 80 Times in 80 Posts
    tried that already it doesn't work not popping up box and still completing form post

    edit: had onsubmit after action="" moved it to before and it works now.

    thanks
    A programmer is just a tool which converts caffeine into code

    My work: http://www.fcsoftware.co.uk && http://www.firstcontactcrm.com
    My hobby: http://www.angel-computers.co.uk
    My life: http://www.furious-angels.com

  • #7
    Regular Coder
    Join Date
    Nov 2007
    Location
    Leeds, UK
    Posts
    514
    Thanks
    24
    Thanked 19 Times in 19 Posts
    Still on a Button in HTML
    if (confirm("Yes or no")) {//if yes
    document.getlElementById("FORM NAME").submit();
    }
    else { // if no
    history.go(-1);
    }

  • #8
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,855
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Quote Originally Posted by hinch View Post
    edit: had onsubmit after action="" moved it to before and it works now.
    The order of attributes doesn't make any difference, you might had missed a quote or something.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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