sindre <si******@c2i.net> wrote in message news:<opsahzcwnbxg0aby@xn--sindres_brbare-8ib>...
Why don't you just use a <p> or <span> or <div> for your link?
I'd do it this way:
<script type="text/javascript">
function conditional_submit (myForm) {
if(confirm("Do you really want to delete?")) {
document.myForm.submit();
} else {
//nothing to do }
}
</script>
<p onclick="conditional_submit(document.getElementByI d('<?php print
"delete$i";?>')">Delete?</p>
Actually it dont. Firstly onclick in div, p og span is not supported by
netscape 6.x. But it wont work either in opera or explorer. Nothing
happens when i move the mouse over the "link" and nothing happens when i
click the word.
Sindre
Sorry, my mistake. I forgot a closing bracket and it should be
myForm.submit(); instead of document.myForm.submit().
Here is an complete example-page, that workes out in Mozilla 1.7,
Netscape 6.2 and IE 6. It does not work in NS 4.75, because this one
does not jet support getElementById. I substituted '<?php print
"delete$i";?>' with 'delete1' in my example. As mortb wrote, you can
place the code of the function in the onclick event directly, depends
on how many forms you have in your page. You could also just send the
name(text!) of the form to the function like
onclick="conditional_submit('delete1');", then, depending on the
browser you could use document.getElementsByName,
document.getElementById or even document.all to get your form-object.
!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