Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Blue Font???

  1. #1
    Regular Coder
    Join Date
    May 2005
    Posts
    220
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Blue Font???

    I'm not too good with javascript, but I had a friend help me get this code down. He is gone now and I need to change the color of the font. Where on earth does it tell my question to be in blue font?

    Code:
    var useranswers = new Array();
    var answered = 0;
    
    function renderQuiz()
    {
    	for(i=0;i<questions.length;i++)
    	{
    		document.writeln('<p class="question">' + questions[i] + ' <span id="result_' + i + '"><img src="blank.gif" style="border:0" alt="" /></span></p>');
    		for(j=0;j<choices[i].length;j++)
    		{
    			document.writeln('<input type="radio" name="answer_' + i + '" value="' + choices[i][j] + '" id="answer_' + i + '_' + j + '" class="question_' + i + '" onclick="submitAnswer(' + i + ', this, \'question_' + i + '\', \'label_' + i + '_' + j + '\')" /><label id="label_' + i + '_' + j + '" for="answer_' + i + '_' + j + '"> ' + choices[i][j] + '</label><br />');
    		}
    	}
    	document.writeln('<p><input type="submit" value="Details" onclick="showScore()" /> <input type="submit" value="Reset Question" onclick="resetQuiz(true)" /></p><p style="display:none"><img src="correct.gif" style="border:0" alt="Correct!" /><img src="incorrect.gif" style="border:0" alt="Incorrect!" /></p>');
    }
    function resetQuiz(showConfirm)
    {
    	if(showConfirm)
    		if(!confirm("Are you sure you want to reset your answer?"))
    			return false;
    			
    	document.location = document.location;
    }
    function submitAnswer(questionId, obj, classId, labelId)
    {
    	useranswers[questionId] = obj.value;
    	document.getElementById(labelId).style.fontWeight = "bold";
    	disableQuestion(classId);
    	showResult(questionId);
    	answered++;
    }
    function showResult(questionId)
    {
    	if(answers[questionId] == useranswers[questionId])
    	{
    		document.getElementById('result_' + questionId).innerHTML = '<a href="../2/2.html"><img src="correct.gif" style="border:0" alt="Correct!" /></a>';
    	}
    	else
    	{
    		document.getElementById('result_' + questionId).innerHTML = '<img src="incorrect.gif" style="border:0" alt="Incorrect!" />';
    	}
    }
    function showScore()
    {
    	if(answered != answers.length)
    	{
    		alert("You have not answered all of the questions yet!");
    		return false;
    	}
    	questionCount = answers.length;
    	correct = 0;
    	incorrect = 0;
    	for(i=0;i<questionCount;i++)
    	{
    		if(useranswers[i] == answers[i])
    			correct++;
    		else
    			incorrect++;
    	}
    	pc = Math.round((correct / questionCount) * 100);
    	alertMsg = "You scored " + correct + " out of " + questionCount + "\n\n";
    	
    	if(pc == 100)
    		alertMsg += response[0];
    	else if(pc >= 90)
    		alertMsg += response[1];
    	else if(pc >= 70)
    		alertMsg += response[2];
    	else if(pc > 50)
    		alertMsg += response[3];
    	else if(pc >= 40)
    		alertMsg += response[4];
    	else if(pc >= 20)
    		alertMsg += response[5];
    	else if(pc >= 10)
    		alertMsg += response[6];
    	else
    		alertMsg += response[7];
    		
    	if(pc < 100)
    	{
    		if(confirm(alertMsg))
    			resetQuiz(false);
    		else
    			return false;
    	}
    	else
    	{
    		alert(alertMsg);
    	}
    }
    function disableQuestion(classId)
    {
    	var alltags=document.all? document.all : document.getElementsByTagName("*")
    	for (i=0; i<alltags.length; i++)
    	{
    		if (alltags[i].className == classId)
    		{
    			alltags[i].disabled = true;
    		}
    	}
    }

  • #2
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    I don't see it any where in your code.

    a) i beleive that blue is the default color for links, if you have specified nothing for link color then it will default to blue.

    b) if you have specified the link color somewhere, it may be in a style sheet, ie: .css file.

  • #3
    Regular Coder
    Join Date
    May 2005
    Posts
    220
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Ah! When you said Css it triggered my memory. I found the issue. It was not in my javascript!

    Thanks for the help!

  • #4
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    haha, no prob ;-)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •