...

View Full Version : Confirmation button on submit



hinch
08-07-2008, 04:42 PM
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 :confused:

Javascript


// confirm unassign
function confirmunassign(){
msg = "You are about to unassign this lead are you sure you wish to do this";
return confirm(msg);
}


Form


<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

barkermn01
08-07-2008, 04:45 PM
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


<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

hinch
08-07-2008, 04:55 PM
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 :)

http://www.furious-angels.com/imagehosting/1489b0cb4de496.jpg

barkermn01
08-07-2008, 05:12 PM
oo the system box
one min

abduraooft
08-07-2008, 05:18 PM
<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>

<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>

hinch
08-07-2008, 05:28 PM
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

barkermn01
08-07-2008, 05:40 PM
Still on a Button in HTML
if (confirm("Yes or no")) {//if yes
document.getlElementById("FORM NAME").submit();
}
else { // if no
history.go(-1);
}

abduraooft
08-07-2008, 05:43 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum