$("#send").live("click",function() {
var answer = $("#answer"); // Holds the answer value
if(answer.val() == $(".flag:visible").attr("alt")) { // Shows flag
$("#result").html("ok"); // If the answer is correct
}else {
$("#result").html("fel"); // If the answer is wrong
}
});
changeFlag();
function changeFlag()
{
var antalFlags = $(".flag").size(); // The number of flags
var slumpad = 0;
$(".flag").eq(slumpad).show(); // This is the part I can't figure out
}
});
</script>
You shouldn't use the right names for your flag images nor for the alt attribute. Too easy to get the info on them. Use numbers instead. Than in javascript:
Code:
<script type='text/javascript'>
var flag = Math.floor((Math.random()*10)+1);
var flag_image = flag+".png";
alert(flag_image);
</script>
Will randomize numbers between 1 and 10 and give you the image name as flag_image