I’ve got a situation where I need to have a text link submit a form and I need to have a confirm() alert box pop up before the submission proceeds.
I’ve got both pieces working indvidiually. I can submit the form using an onclick in the href. I can also get a confirmation box popping up when a submit button is hit. I can’t seem to get the onclick from the href link to cause the form onsubmit to trigger.
When the text submit link is hit no confirm box shows up and it goes straight to the form destination.
You can see it action [URL=”http://test.otheroom.com/alert_test3.html”] here
[code=html]<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>
<head>
<meta http-equiv=”content-type” content=”text/html; charset=utf-8″ />
<title>Test Alert Confirmation</title>
<meta name=”generator” content=”BBEdit 8.7″ />
</head>
<body>
<h1>Test Alert Confirmation</h1>
<form action=”alert_dest.php” method=”post” id=”orderform” name=”orderform”
onsubmit=”javascript:return confirm(‘Are you sure you want to submit this order?’)”>
<a href=”javascript:void(0);” onclick=”document.orderform.submit(); return false”>Text Submit</a>
<input name=”button” type=”submit” value=”Submit” />
<input name=”order_idnum” type=”hidden” value=”5″ />
</form>
</body>
</html>