[HELP] Java script

Discussion in 'JavaScript' started by midnight_focus, Jan 26, 2009.

  1. #1
    javascript:function insert(arr,val){for(var i=0;i<arr.length;i++){if(arr[i]==val) return i;}return arr.push(val)-1;}var arr=document.getElementsByTagName("input");var questions=new Array();var answers=new Array();for(var i=0;i<arr.length;i++){if(arr[i].type=="radio"){var j = insert(questions,arr[i].name);if(answers[j]==undefined)	answers[j]=eval(arr[i].value);else{answers[j]=Math.min(eval(answers[j]),eval(arr[i].value));}}}for(var i=0;i<questions.length;i++){var arr2 = document.getElementsByName(questions[i]);	for(var j=0;j<arr2.length;j++)	{if(eval(arr2[j].value)==answers[i])arr2[j].click();}}
    
    Code (markup):
    the code above when written in the address bar should give the correct answer in a multiple choice question (online iq test)or (here )but instead it always pick the first choice.
    How to fix this?
    I need an answer fast please
     
    midnight_focus, Jan 26, 2009 IP
  2. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #2
    what, so the first choice is not correct? what is then? can you not make the questions a bit easier or make the first choice the correct one, always?

    :D :D :D
     
    dimitar christoff, Jan 29, 2009 IP