Topic: confirm submit (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=31077" title="Pages that link to Topic: confirm submit (Page 1 of 1)" rel="nofollow" >Topic: confirm submit <span class="small">(Page 1 of 1)</span>\

 
gilbertsavier
Obsessive-Compulsive (I) Inmate

From:
Insane since: Jun 2009

posted posted 06-26-2009 15:01

Hi there,

I want to update my form that makes me delete items from my site.

The nw part should be a alert to confirm the submit. I got it this far:

Code:
<script type="text/javascript">
function areyoureallysure()
{
var messageb = "Are you sure?";
if (confirm(messageb))
return true;
else
return false;
}
</script>
PHP Code:
<?
echo"
<form id=\"BestellingVerwijderen\" action=\"details.php\" method=\"post\" name=\"BestellingVerwijderen\" enctype=\"multipart/form-data\">
<input type=\"hidden\" name=\"n\" value=\"$n\">
<input type=\"hidden\" name=\"d\" value=\"d\">
<table width=\"500px\" border=\"0px\" cellspacing=\"0px\" cellpadding=\"5px\">
<tr>
<td align=\"center\" class=\"groen\" colspan=\"2\">
<a href=\"javascript:areyoureallysure();\" class=\"pointer\">
<font color=\"red\">Klik hier om deze uitgave te verwijderen.</font></a>";
echo"</td>
</tr>
</table>
</form>
";
?>
The alert is there.. but no mather what I click (cancel or aprove) it will return to the page it comes from
instead of further submit the form and delete the part I wanted to....

Thanks & Regards
Lokananth

Live chat
http://www.mioot.com

reisio
Paranoid (IV) Inmate

From: Florida
Insane since: Mar 2005

posted posted 06-26-2009 15:17

Try using an input type="submit" with onclick, or an onsubmit in the form tag.

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 06-26-2009 15:55

yeah, you're not telling the link where to actually go...

what you need is either to do what reisio said (and tie the javascript conform to the onsubmit of the form), or you need to tweak your javascript to actually submit the form.

The former (reisio's) is they way prettier method!

DL-44
Lunatic (VI) Inmate

From: under the bed
Insane since: Feb 2000

posted posted 06-27-2009 05:47

On a completely unrelated note: why on earth would you wrap your HTML in PHP tags and echo it? What a pain in the ass escaping all those quotes for no reason...

(and...tables and font tags? you are making the children cry!)

reisio
Paranoid (IV) Inmate

From: Florida
Insane since: Mar 2005

posted posted 06-27-2009 18:08
quote:
DL-44 said:

why on earth

That's the PHP motto.

yossiadmon
Obsessive-Compulsive (I) Inmate

From: Israel
Insane since: Sep 2009

posted posted 09-08-2009 13:37

don't forget that the enter key when focusing on form component is identical to pressing a submit button therefore you can choose from the following:
a) add a submit button (input type="submit") with no validation and add to the form onsubmit="return areyoureallysure()" (or perform inline confirm code)
b) add a button (input type="button") with full validation call (onclick) performing javascript submit to the form (document.getElementById(form id).submit()) and add to the form onsubmit="return areyoureallysure()" (or perform inline confirm code)

personally I prefer the following code

code:
<form onsubmit="return confirm('Are you sure?')">
    ...
    <input type="submit">
</form>

coach
Nervous Wreck (II) Inmate

From:
Insane since: May 2011

posted posted 05-31-2011 11:04
Edit TP: spam removed


Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu