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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

confirm box 1

Status
Not open for further replies.

teroy

Programmer
Oct 17, 2000
67
AU
Hi there. When i want to use a confirm button using a form i do as follows

-----------------------------------------------------------
function checkform2()
{
// Uses a confirm box
var yes = self.confirm("Are you sure?");

return yes;

}

<FORM name=&quot;&quot; method=&quot;post&quot; action=&quot;&quot; onSubmit=&quot;return checkform()&quot;>

---------------------------------------------------------

If i wanted to do the same thing via a <a href> how would i go about doing it?

Thanks in Advance
 
Hi Teroy,

Try this,
<script>
function checkform2()
{
if (self.confirm(&quot;Are you sure?&quot;))
document.MyForm.submit()
}
</script>

<FORM name=&quot;MyForm&quot; method=&quot;post&quot; action=&quot;somewhere&quot;>
<A href=&quot;javascript:checkform2()&quot;>something</a>
</form>

hope this helps,
Chiu Chan
cchan@emagine-solutions.com
 
yup it would nearly work.
Only problem is i don't use a <form> in my current scenario
The <a href> contains something like <a href=delete.cgi>Delete</a>

So..is there a way of combing the 2..?
ie delete.cgi and javascript:checkform2()
and not actually <a hrefing> to delete.cgi if checkform2() returns a negative value

Thanks!
 
Thanks pepperpepsi..

that worked perfectly :))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top