Привет.
Есть скрипт голосования, результат выводит в xml.
В опере и ИЕ все ок, а вот в мозилле ерунда какая-то получается, понять не могу, что не так.
ПХП:
echo '<?xml version="1.0" ?>';
$res = mysql_query("SELECT * FROM `poller` WHERE `id` = '".$pollId."';") or die(mysql_error());
if ($inf = mysql_fetch_array($res)) {
?>
<pollerTitle><?php echo $inf["pollerTitle"]; ?></pollerTitle>
<?php
$resOptions = mysql_query("SELECT `id`, `optionText` FROM `poller_option` WHERE `pollerID` = '".$inf["id"]."' ORDER BY `pollerOrder`;") or die(mysql_error());
while ($infOptions = mysql_fetch_array($resOptions)) {
$querycount = mysql_query("SELECT `id` FROM `poller_vote` WHERE `pollerID` = '".$pollId."' AND `optionID` = '".$infOptions["id"]."';") or die(mysql_error());
$count = mysql_num_rows($querycount);
echo "<option>\n
\t<optionText>".$infOptions["optionText"]." (".$count.")</optionText>\n
\t<optionId>".$infOptions["id"]."</optionId>\n";
$resVotes = mysql_query("SELECT count(id) FROM `poller_vote` WHERE `optionID` = '".$infOptions["id"]."' AND `pollerID` = '".$pollId."';");
if($infVotes = mysql_fetch_array($resVotes)) {
echo "\t<votes>".$infVotes["count(id)"]."</votes>\n";
}
echo "</option>";
}
}
function showVoteResults(pollId,ajaxIndex) {
document.getElementById('poller_waitMessage' + pollId).style.display = 'none';
var xml = ajaxObjects[ajaxIndex].response;
xml = xml.replace(/\n/gi,'');
var reg = new RegExp("^.*?<pollerTitle>(.*?)<.*$","gi"),
pollerTitle = xml.replace(reg,'$1');
var resultDiv = document.getElementById('poller_results' + pollId);
var titleP = document.createElement('P');
titleP.className='result_pollerTitle';
titleP.innerHTML = pollerTitle;
resultDiv.appendChild(titleP);
var options = xml.split(/<option>/gi);
pollVotes[pollId] = new Array();
totalVotes[pollId] = 0;
for(var no=1;no<options.length;no++) {
var elements = options[no].split(/</gi);
var currentOptionId = false;
for (var no2 = 0; no2 < elements.length; no2++) {
if (elements[no2].substring(0,1) != '/') {
var key = elements[no2].replace(/^(.*?)>.*$/gi,'$1');
var value = elements[no2].replace(/^.*?>(.*)$/gi,'$1');
if (key.indexOf('optionText') >= 0) {
var pOption = document.createElement('P');
pOption.className='result_pollerOption';
pOption.innerHTML = value;
resultDiv.appendChild(pOption);
}
if(key.indexOf('optionId')>=0){
currentOptionId = value/1;
}
if(key.indexOf('votes')>=0){
var voteDiv = document.createElement('DIV');
voteDiv.className='result_pollGraph';
resultDiv.appendChild(voteDiv);
var leftImage = document.createElement('IMG');
leftImage.src = voteLeftImage;
voteDiv.appendChild(leftImage);
var numberDiv = document.createElement('DIV');
numberDiv.style.backgroundImage = 'url(\'' + voteCenterImage + '\')';
numberDiv.innerHTML = '0%';
numberDiv.id = 'result_voteTxt' + currentOptionId;
voteDiv.appendChild(numberDiv);
var rightImage = document.createElement('IMG');
rightImage.src = voteRightImage;
voteDiv.appendChild(rightImage);
pollVotes[pollId][currentOptionId] = value;
totalVotes[pollId] = totalVotes[pollId]/1 + value/1;
}
}
}
}
var totalVoteP = document.createElement('P');
totalVoteP.className = 'result_totalVotes';
totalVoteP.innerHTML = txt_totalVotes + totalVotes[pollId];
voteDiv.appendChild(totalVoteP);
setPercentageVotes(pollId);
slideVotes(pollId,0);
}
В результате:
Opera
IE
FireFox
Что не так ?
з.ы. На кол-во голосов внимания не обращайте.