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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Oct 2011
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Help with onSubmit in javascript

    So I have two buttons, and for one, it is simply "submit", no on submit needs to be used for it. The other one is "delete" and I wanna have a confirm box open when you click delete saying something like "are you sure you want to delete?" and clicking yes would delete it and no would not. Here is the javascript I have so far for it.

    Code:
    <script type="text/javascript">
    function OnButton1()
    {
        document.simpForm.action =  "<?php php stuff here ?>";
        document.simpForm.target = "_self";    
    
        document.simpForm.submit();             // Submit update
    
        return true;
    }
    
    function OnButton2()
    {
        document.simpForm.action = "delete.php?id=<?php php stuff here ?>";
        document.simpForm.target = "_self";   
    	
        document.simpForm.submit();             // Delete the company
    
        return true;
    }
    
    </script>
    Any help would be GREAT! Javascript is not my strong point
    Last edited by brittneykt; 10-23-2011 at 08:55 PM.

  • #2
    Regular Coder
    Join Date
    Apr 2005
    Location
    Texas
    Posts
    448
    Thanks
    24
    Thanked 63 Times in 63 Posts
    Is this what your looking for?
    Code:
    function OnButton2()
    {
        if(!confirm('are you sure?'))return false;
        document.simpForm.action = "delete.php?id=<?php php stuff here ?>";
        document.simpForm.target = "_self";   
    	
        document.simpForm.submit();             // Delete the company
    
        return true;
    }
    
    </script>

  • Users who have thanked blaze4218 for this post:

    brittneykt (10-23-2011)

  • #3
    New to the CF scene
    Join Date
    Oct 2011
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Yes!!!!!!!!!! Thank you so much for your help!!! It worked!!

    Quote Originally Posted by blaze4218 View Post
    Is this what your looking for?
    Code:
    function OnButton2()
    {
        if(!confirm('are you sure?'))return false;
        document.simpForm.action = "delete.php?id=<?php php stuff here ?>";
        document.simpForm.target = "_self";   
    	
        document.simpForm.submit();             // Delete the company
    
        return true;
    }
    
    </script>


  •  

    Tags for this Thread

    Posting Permissions

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