Моя функция javascript просит определить переменные, которые перемещают пользователя через вопросы викторины, добавляя или вычитая числа и достигая суммы, которая вызывается позже в форме HTML. Все работает, но вместо окончания цикла на стороне клиента он мигает на экране и исчезает, как если бы скрипт ждал, чтобы пользователь снова начал вопросы. Правильно ли я чувствую, что проблема где-то в цикле javascript? Спасибо:
var max_points = 28;
var total_points = 0;
var percentage_addiction = 0;
var reloadVar = "yes";
function makeChanges(currentQuestion, nextQuestion, points){
//display only needed question
document.getElementById(currentQuestion).style.display="none";
document.getElementById(nextQuestion).style.display="block";
//add total points
total_points = total_points + points;
//show image that corresponds to points
for( var i = 0; i < 15; i++)
{
if( ( total_points > i*2 ) && ( total_points <= (i+1)*2 ) )
{
//hide image that was shown previously
document.getElementById('img' + i).style.display="none";
//display image that corresponds points
document.getElementById("img"+(i+1)).style.display="block";
}
}
percentage_addiction = Math.floor( (total_points/max_points)*100 );
if( nextQuestion == "result" )
{
document.getElementById("code").style.display="block";
//document.form1.percentage.value=escape(document.percentage);
location.replace('http://URL?percentage='+percentage_addiction+'&end=yes&oneSubmit=yes');
}
//update percentage in page
document.getElementById('percentage').innerHTML = percentage_addiction;
document.getElementById('percentage2').innerHTML = percentage_addiction;
}
function submitForm(){
document.form1.submit();
}