modify this code .. please help me?
- by Sam
i wana modify this code from static choices to dynamic this for 3 choices var PollhttpObject=null;
function DoVote()
{if(document.getElementById('PollRadio1').checke d)DoVote_Submit(1);else if(document.getElementById('PollRadio2').checked)DoVote_Submit(2);else if(document.getElementById('PollRadio3').checked)DoVote_Submit(3);else alert('?????: ?????? ?????? ??? ?????????? ??????? ?? ????? ??? ?? ???????');return false;}
function DisbalePoll(TheCase)
{document.getElementById('VoteBttn').onclick=function(){alert('!?????? ??? ?? ??????? ??????');}
document.getElementById('PollRadio1').disabled='true';document.getElementById('PollRadio2').disabled='true';document.getElementById('PollRadio3').disabled='true';if(TheCase=='EXPIRED')
{document.getElementById('VoteBttn').src='images/design/VoteBttn_OFF.jpg';document.getElementById('ResultBttn').src='images/design/ResultsBttn_OFF.jpg';document.getElementById('VoteBttn').onclick='';document.getElementById('ResultBttn').onclick='';document.getElementById('ResultBttn').style.cursor='';document.getElementById('VoteBttn').style.cursor='';}}
function DoVote_Submit(VoteID)
{if(VoteID!=0)DisbalePoll();try{PollhttpObject=getHTTPObject();if(PollhttpObject!=null)
{PollhttpObject.onreadystatechange=PollOutput;PollhttpObject.open("GET","Ajax.aspx?ACTION=POLL&VOTEID="+ VoteID+"&RND="+ Math.floor(Math.random()*10001),true);PollhttpObject.send(null);}}
catch(e){}
return false;}
function PollOutput(){if(PollhttpObject.readyState==4)
{var SearchResult=PollhttpObject.responseText;document.getElementById('PollProgress').style.display='none';document.getElementById('PollFormDiv').style.display='block';if(SearchResult.length=2&&SearchResult.substr(0,2)=='OK')
{var ReturnedValue=SearchResult.split("#");document.getElementById('PollBar1').style.width=0+'px';document.getElementById('PollBar2').style.width=0+'px';document.getElementById('PollBar3').style.width=0+'px';document.getElementById('PollRate1').innerHTML="0 (0%)";document.getElementById('PollRate2').innerHTML="0 (0%)";document.getElementById('PollRate3').innerHTML="0 (0%)";window.setTimeout('DrawPollBars(0, '+ ReturnedValue[1]+', 0, '+ ReturnedValue[2]+', 0, '+ ReturnedValue[3]+')',150);}
else if(SearchResult.length=2&&SearchResult.substr(0,2)=='NO')
{alert("?????: ??? ??? ???????? ?????");}}
else
{document.getElementById('PollProgress').style.display='block';document.getElementById('PollFormDiv').style.display='none';}}
function DrawPollBars(Bar1Var,Bar1Width,Bar2Var,Bar2Width,Bar3Var,Bar3Width)
{var TotalVotes=parseInt(Bar1Width)+parseInt(Bar2Width)+parseInt(Bar3Width);var IncVal=parseFloat(TotalVotes/10);var NewBar1Width=0;var NewBar2Width=0;var NewBar3Width=0;var Bar1NextVar;var Bar2NextVar;var Bar3NextVar;if(parseInt(parseInt(Bar1Var)*200/TotalVotes)0)NewBar1Width=parseInt(Bar1Var)*200/TotalVotes;else if(Bar1Var0)NewBar1Width=1;else NewBar1Width=0;if(parseInt(parseInt(Bar2Var)*200/TotalVotes)0)NewBar2Width=parseInt(Bar2Var)*200/TotalVotes;else if(Bar2Var0)NewBar2Width=1;else NewBar2Width=0;if(parseInt(parseInt(Bar3Var)*200/TotalVotes)0)NewBar3Width=parseInt(Bar3Var)*200/TotalVotes;else if(Bar3Var0)NewBar3Width=1;else NewBar3Width=0;document.getElementById('PollBar1').style.width=NewBar1Width+'px';document.getElementById('PollBar2').style.width=NewBar2Width+'px';document.getElementById('PollBar3').style.width=NewBar3Width+'px';document.getElementById('PollRate1').innerHTML=parseFloat(Bar1Var).toFixed(0)+" ("+ parseFloat(parseFloat(Bar1Var)/TotalVotes*100).toFixed(1)+"%)";document.getElementById('PollRate2').innerHTML=parseFloat(Bar2Var).toFixed(0)+" ("+ parseFloat(parseFloat(Bar2Var)/TotalVotes*100).toFixed(1)+"%)";document.getElementById('PollRate3').innerHTML=parseFloat(Bar3Var).toFixed(0)+" ("+ parseFloat(parseFloat(Bar3Var)/TotalVotes*100).toFixed(1)+"%)";if(Bar1Var!=Bar1Width||Bar2Var!=Bar2Width||Bar3Var!=Bar3Width)
{if(parseFloat(Bar1Var)+IncVal<=parseInt(Bar1Width))Bar1NextVar=parseFloat(Bar1Var)+IncVal;else Bar1NextVar=Bar1Width;if(parseFloat(Bar2Var)+IncVal<=parseInt(Bar2Width))Bar2NextVar=parseFloat(Bar2Var)+IncVal;else Bar2NextVar=Bar2Width;if(parseFloat(Bar3Var)+IncVal<=parseInt(Bar3Width))Bar3NextVar=parseFloat(Bar3Var)+IncVal;else Bar3NextVar=Bar3Width;window.setTimeout('DrawPollBars('+ Bar1NextVar+', '+ Bar1Width+', '+ Bar2NextVar+', '+ Bar2Width+', '+ Bar3NextVar+', '+ Bar3Width+')',80);
}}