これはフォーラムへの私の最初の質問です。有用で迅速な回答を得られることを願っています..
ここに私のphpコードがあります:
<a href="<?php echo $sp['url']; ?>" id="bstd<?php echo $sp['Id']; ?>" target="_blank" onclick="clk('<?php echo $sp['Id']; ?>','<?php echo $_REQUEST['uid']; ?>')"><img src="images/add.jpj"></a>
および次の JavaScript 関数:
<script>
function clk(a,b){
......... the ajax code to use a,b as variables
........
}
</script>
これはすべて正常に機能しています...しかし。別のJavaScript関数で...のonclickとhrefを有効/無効にしたい
<script>
function disb(p){
if(p>5){
av=document.getElementById(bstd); //working fine
av.setAttribute("href", "#"); //working fine
av.style.cursor="default"; //working fine
av.onclick = cancel; //not working... i want to disable the onclick.
}else{
av=document.getElementById(bstd); //working fine
av.setAttribute("href", ???); //i want the previous code url link automatically..as it was dynamic and coming from php.
av.style.cursor="pointer"; //working fine
av.onclick = ???; //i want the onclick function clk(with the dynamic php values).
}
}
</script>
私は理解するのが簡単ではないことを知っています..私が欲しいもの...だからここに簡単な説明があります...
これをクリックすると画像「a1」があります。この画像をクリックした回数を数えます...そして今、この後...5回以上クリックした場合...その後のみ...タグのonclick有効にする必要があります...それ以外の場合は、クリックするたびにタグのonclickを無効にする必要があります(下向きにカウントされる別の画像があるため、有効または無効になっているたびに無効にする必要があります)
それが理にかなっているのかどうかはわかりません...しかし、私は解決策が欲しいです...