Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

confirm(); 1

Status
Not open for further replies.

gus121

Technical User
May 9, 2002
298
GB
Hi I wish to have a confirmation box come up before subiting content of an HTML form.

ie. if Yes then submit.

ie. if False then don't submit.

Please can some one help?

regards

The Form:

<form name=&quot;form1&quot; method=&quot;post&quot; onSubmit=&quot;confirm_entry()&quot; >
<input type=&quot;hidden&quot; name=&quot;Email_Importance&quot; value=&quot;<%= Email_Importance %>&quot;>

<input type=&quot;hidden&quot; name=&quot;html_Email_Body&quot; value=&quot;<%=Server.HTMLEncode(html_Email_Body)%>&quot;>

<input type=&quot;hidden&quot; name=&quot;Email_Body&quot; value=&quot;<%=Email_Body%>&quot;>

The Javascript:

<script language=&quot;JavaScript&quot;>
<!--


winName = window.open(email,&quot;send_email&quot;);

function confirm_entry()
{
input_box=confirm(&quot;Are You Sure? Email will be sent to all customers!&quot;);
if (input_box==true)
{
email('about:blank');
f = document.forms[0];
f.target = winName;
f.action = 'email_control.asp?action=send';
f.submit();

}
}

-->
</script>

Angus
 
function confirm_entry()
{
if (confirm(&quot;Are You Sure? Email will be sent to all customers!&quot;))
email('about:blank');
f = document.forms[0];
f.target = winName;
f.action = 'email_control.asp?action=send';
f.submit();

}
}
 
Sorry I use a different writing style from your example. I'm missing a bracket.

function confirm_entry()
{
if (confirm(&quot;Are You Sure? Email will be sent to all customers!&quot;))
{
email('about:blank');
f = document.forms[0];
f.target = winName;
f.action = 'email_control.asp?action=send';
f.submit();

}
}
 
you also need to change
onSubmit=&quot;confirm_entry()&quot;

to
onSubmit=&quot;return confirm_entry()&quot;

=========================================================
try { succeed(); } catch(E) { tryAgain(); }
-jeff
 
Hi gph and jemminger. Thanks for your help. However I still have problems with this script.

In that it does not return properly even with the onSubmit=&quot;return confirm_entry()&quot; If you cancel. I get a blank page any ideas how to sort this out? The URL is still fine.

I also had to alter the code to get it to run (probably because I did not explain my self very well and i was attempting to coble together other peoples code). Is this OK?


function confirm_entry()
{
if (confirm(&quot;Are You Sure? Email will be sent to all customers!&quot;))
{
location.href = 'about:blank';
f = document.forms[0];
f.action = 'email_control.asp?action=send';
f.submit();

}
}
-->
It also sent me 2 emails when I was expecting 1 from the next page script is this to do with the javascript.

Thanks again for your help.




Angus
 
this &quot;Submit&quot; button that u have what is its type?

<input type=&quot;submit&quot; (OR) <input type=&quot;button&quot; onclick=&quot;Submit_The_Form&quot;>?

also try this:
function confirm_entry()
{
if (confirm(&quot;Are You Sure? Email will be sent to all customers!&quot;))
{
location.href = 'about:blank';
f = document.forms[0];
f.action = 'email_control.asp?action=send';
f.submit();

}
else
return false;
}


Known is handfull, Unknown is worldfull
 
Hi vbkris. Yes thanks that bit of extra code solved my cancel confirm problem if you follow me. thanks.

However the submit twice issue is a wierd one and it is definatly something 2 do with the javascript. As if i refresh the next page it only sends 1 e-mail. There is deffinatly no calls to any javascript functions from the submit button. As the button is just a plain old

<input type=&quot;submit&quot; name=&quot;submit email&quot; value=&quot;submit email&quot;>

thanks


Angus
 
change ur button to this:
<input type=&quot;button&quot; name=&quot;submit email&quot; value=&quot;submit email&quot;>

or remove f.submit() from the code...

Known is handfull, Unknown is worldfull
 
I have got a feeling i have seen this before so I tested it on a colleages computer and it only submited it once with the (submit) button. weird with the same version of explorer.

I then tried removing //f.submit() you were right it works on both me and me colleages as it should.

thanks

Angus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top