Debt Consolidation - Credit Report - Deaf Topics - Free Movies - Debt Consolidation

PDA

View Full Version : make <a href disabled after click once


koemans
Jun 21st 2007, 11:53 pm
I'd like to make the link disable after user click the link!
now i've the code for it, but it's not working if i use $PHP_SELF!



<html>
<head>
<SCRIPT>

var canNav = false;

function canNavigate(linkObj) {
if (linkObj != null) {
if (document.all('lnk1').disabled == true) {
canNav = false;

} else {
document.all('lnk1').disabled = true;
canNav = true;
}
return canNav;
}
}

</SCRIPT>

</HEAD>

<BODY>
<a id="lnk1" href="http://www.microsoft.com/" onclick="return canNavigate(document.all('lnk1'));">Click here</a><p>
</BODY>
</HTML>



here is the href code:


<a id="lnk1" href="<?echo $PHP_SELF?>?kode_trans_far=<? echo $no_transaksi?>&kode_layanan=<? echo $kode_layanan?>&batal_transaksi=batal_transaksi" class="link01" <?konfirmasi('Anda yakin akan membatalkan transaksi ini?');?> onclick="return canNavigate(document.all('lnk1'));" ><img src="/images/icon_hapus.gif" alt="Batal Transaksi" border="0"></a>


any idea..?
Please...help me...!!!

ajsa52
Jun 22nd 2007, 12:30 am
Try with this:


<html>
<head>
<script type = "text/javascript">
function f_click( t )
{
at = t.getAttributeNode("href");
window.open( at.value );
t.removeAttributeNode( at );
}
</script>
</head>
<body>
<a href="http://www.google.com" onclick="f_click(this);">Go to Google</a>
</body>
</html>

Mike H.
Jun 22nd 2007, 5:10 am
koemans:

I see that you are using: class="link01" within the link, but it doesn't look like it's needed because you are using an image for the link. So, change the class to the PHP_SELF string, as shown:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Any Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">

function noLink(nLink){

var nHREF = nLink.className;
if (nHREF != "")
{
nLink.className = "";
//window.open(nHREF);
// or
//self.location.href = nHREF;
}
}

</script>
<style type="text/css">

body {background-color:#eae3c6;margin-top:60px}

</style>
</head>
<body>
<a href="#" class="<?echo $PHP_SELF?>?kode_trans_far=<? echo $no_transaksi?>&kode_layanan=<? echo $kode_layanan?>&batal_transaksi=batal_transaksi" onclick="noLink(this);return false"><img src="/images/icon_hapus.gif" alt="Batal Transaksi" border="0"></a>
</body>
</html>