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 10-23-2011, 07:37 PM   PM User | #1
brittneykt
New to the CF scene

 
Join Date: Oct 2011
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
brittneykt is an unknown quantity at this point
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..
brittneykt is offline   Reply With Quote
Old 10-23-2011, 07:56 PM   PM User | #2
blaze4218
Regular Coder

 
Join Date: Apr 2005
Location: Texas
Posts: 448
Thanks: 24
Thanked 63 Times in 63 Posts
blaze4218 is an unknown quantity at this point
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>
blaze4218 is offline   Reply With Quote
Users who have thanked blaze4218 for this post:
brittneykt (10-23-2011)
Old 10-23-2011, 08:48 PM   PM User | #3
brittneykt
New to the CF scene

 
Join Date: Oct 2011
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
brittneykt is an unknown quantity at this point
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>
brittneykt is offline   Reply With Quote
Reply

Bookmarks

Tags
javascript, onsubmit, submit

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 04:04 PM.


Advertisement
Log in to turn off these ads.