Forum Moderators: open
function voting(postid)
{
$("voteid"+postid).innerHTML="Loading...";
new Ajax.Request("/voting.php", {method:"post", postBody:"postid="+postid});
new Ajax.Updater("voteid"+postid, "/voting.php");
$("voteid"+postid).innerHTML.replace("javascript:voting("+postid+")","");
}
<a href="javascript:voting(4)" id="voteid4">
$("voteid"+postid).replace("javascript:voting("+postid+")","");
Although, I don't think it will accomplish what you want to accomplish. Post back if that's not what you expected.
function voting(postid)
{
$("voteid"+postid).innerHTML="Loading...";
new Ajax.Request("/voting.php", {method:"post", postBody:"postid="+postid});
new Ajax.Updater("voteid"+postid, "/voting.php");
$('voteid'+postid).replace('Voted','');
var total=$('total'+postid)+1;
$('total'+postid).innerHTML=total;
}
<font id="total4">1</font><a href="javascript:voting(4)" id="voteid4">Add Vote</a>
[edited by: BlackRaven at 6:33 pm (utc) on May 1, 2007]
.innerHTMLbut not referencing that to get the total back out of it. The two forms need to match:
var total=$('total'+postid)[b].innerHTML[/b] +1;
$('total'+postid)[b].innerHTML[/b]=total;
See what I mean? Now,
.innerHTMLis probably considered a string so you'll see concatenation instead of addition when you add that 1 and you probably would prefer "5" over "11111" right? :)
So just cast the
.innerHTMLas an integer before performing the addition:
var total= [b]parseInt([/b]$('total'+postid).innerHTML[b])[/b] +1;
$('total'+postid).innerHTML=total;