MEM
MEM

Reputation: 31387

html question - button over anchor?

<button onclick="aprove(<?php echo $d["cod_team"]; ?>)">Aprove</button>
<button onclick="refuse(<?php echo $d["cod_team"] ?>)">Refuse</button>

1) How can we give this same instructions to a A element?
2) Are there any cross-browser issues that I should be aware of?

K. Regards, MEM

Upvotes: 0

Views: 606

Answers (3)

Jared Farrish
Jared Farrish

Reputation: 49238

<a href="javascript:aprove(<?php echo $d["cod_team"]; ?>)">Approve</a>
<a href="javascript:refuse(<?php echo $d["cod_team"]; ?>)">Refuse</a>

Also:

<a href="#" onclick="aprove(<?php echo $d["cod_team"]; ?>)">;return false;">Approve</a>
<a href="#" onclick="refuse(<?php echo $d["cod_team"]; ?>)">;return false;">Refuse</a>

And, just for grins:

<a href="javascript:aprove(<?=$d["cod_team"]?>)">Approve</a>
<a href="javascript:refuse(<?=$d["cod_team"]?>)">Refuse</a>

And if you want a fallback:

<a href="approve.php?cod_team=<?=$d["cod_team"]?>" onclick="aprove(<?=$d["cod_team"]?>)">;return false;">Approve</a>
<a href="refuse.php?cod_team=<?=$d["cod_team"]?>" onclick="refuse(<?=$d["cod_team"]?>)">;return false;">Refuse</a>

Plus, there are other ways innumerate.

By the way, you misspelled approve in the function name.

Upvotes: 1

Lake
Lake

Reputation: 21

same way:

<a href="javascript:void(0)" onclick="aprove(<?php echo $d["cod_team"]; ?>)">Aprove</a>

The javascript:void(0) part prevents the default behavior of the href thus preventing any page from loading.

Upvotes: 1

Marc B
Marc B

Reputation: 360872

<a href="#" onclick="...">Approve</a>

The # for the url guarantees that the browser won't leave this page, and otherwise the semantics would stay the same.

Upvotes: 2

Related Questions