sindre wrote:
[color=blue][color=green]
> > !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
> > <html>
> > <head>
> > <title>tests</title>
> > <meta http-equiv="Content-Type" content="text/html;
> > charset=iso-8859-15">
> >
> > <script type="text/javascript">
> > function conditional_submit (myForm) { if(confirm("Do you really want
> > to delete?")) myForm.submit() }
> > </script>
> >
> > <body>
> >
> > <p onclick="conditional_submit(document.getElementByI d('delete1'))"
> > style="cursor:pointer">Delete?</p>
> > <br>
> > <div onclick="conditional_submit(document.getElementByI d('delete1'))"
> > style="cursor:pointer">Delete?</div>
> > <br>
> > <span onclick="conditional_submit(document.getElementByI d('delete1'))"
> > style="cursor:pointer">Delete?</span>
> > <br><br>
> > <a href="#"
> > onclick="conditional_submit(document.getElementByI d('delete1'));return(false);">Delete?</a>
> > <br><br>
> > <a
> > href=javascript
:conditional_submit(document.getEle mentById('delete1'));>Delete?</a>
> > <br><br><form name="delete1" id="delete1" action="if1.html"
> > method="get" target="_self">
> > <input type="text" size="20" maxlength="30" name="myText">
> >
> > </form>
> >
> > </body>
> > </html>
> >
> > Recommendation: Use CSS to format the links
> >
> > cu, Michael[/color]
>
> Sorry,
> But It did not work. I used cut and paste the whole section. None of the
> links worked here:-)
>
> Sindre[/color]
If you copied and pasted it verbatim, then the call to "confirm()" probably wrapped, which would
have resulted in a syntax error.
I just tested the code (after cleaning it up a bit) and it works fine:
<html>
<head>
<script type="text/javascript">
function confirm_delete(theForm) {
// DO NOT LET THE NEXT LINE WRAP
if (confirm("Do you really want to delete?")) {
theForm.submit();
}
}
</script>
</head>
<body>
<P>:
<p
onclick="confirm_delete(document.forms['delete1']);"
style="cursor:pointer;"[color=blue]
>Delete?</p>[/color]
<DIV>:
<div
onclick="confirm_delete(document.forms['delete1']);"
style="cursor:pointer;"[color=blue]
>Delete?</div>[/color]
<br>
<SPAN>:
<span
onclick="confirm_delete(document.forms['delete1']);"
style="cursor:pointer;"[color=blue]
>Delete?</span>[/color]
<br>
<br>
<A>:
<a
href="#"
onclick="
confirm_delete(document.forms['delete1']);
return false;
"[color=blue]
>Delete?</a>[/color]
<br><br>
<form name="delete1" action="action.cgi" method="get">
<input type="text" size="20" name="myText">
</form>
</body>
</html>
Everything is split across multiple lines to try make it clearer and to try to avoid
inappropriate line breaks caused by your news reader software.
--
| Grant Wagner <gwagner@agricoreunited.com>
* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html
* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp
* Netscape 6/7 DOM Reference available at:
*
http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
*
http://www.mozilla.org/docs/web-deve...upgrade_2.html