Body onload or $links JavaScript not working

reybies

New Member
In advance, thank you so much for anyone that helps me. For some reason, the body onload event isn't working and I'm not sure as to why. Everything looks correct, but it seems the JavaScript isn't firing. Also, this is in a Drupal 7 module. \[code\]$links[] = '<script type="text/javascript"> function class_roll() { // Car Classes var classes = ["Class - B", "Class - A", "Class - S", "Class - R3", "Class - R2", "Class - R1"], classToUseRnd1 = classes[Math.floor(Math.random() * classes.length)]; classToUseRnd2 = classes[Math.floor(Math.random() * classes.length)]; classToUseRnd3 = classes[Math.floor(Math.random() * classes.length)]; document.getElementById("crollRnd1").innerHTML = classToUseRnd1 ; document.getElementById("crollRnd2").innerHTML = classToUseRnd2 ; document.getElementById("crollRnd3").innerHTML = classToUseRnd3 ; } function track_roll() { var tracks = ["Track - Clear Springs Circuit", "Track - Festival North Circuit", "Track - Beaumont Circuit", "Track - Finley Dam Circuit", "Track - Gladstone Circuit", "Track - Clifton Valley Trail", "Track - Gladstone Trail", "Track - Red Rock Descent", "Track - Red Rock Hill Climb"], trackToUseRnd1 = tracks[Math.floor(Math.random() * tracks.length)]; trackToUseRnd2 = tracks[Math.floor(Math.random() * tracks.length)]; trackToUseRnd3 = tracks[Math.floor(Math.random() * tracks.length)]; document.getElementById("trollRnd1").innerHTML = trackToUseRnd1 ; document.getElementById("trollRnd2").innerHTML = trackToUseRnd2 ; document.getElementById("trollRnd3").innerHTML = trackToUseRnd3 ; } </script>'; echo '<html>', "\n"; echo '<body onload="class_roll(); track_roll();">', "\n"; echo '<h4>Round 1</h4>', "\n"; echo '<p id="crollRnd1">Class - </p>', "\n"; echo '<p id="trollRnd1">Track - </p>', "\n"; echo '<h4>Round 2</h4>', "\n"; echo '<p id="crollRnd2">Class - </p>', "\n"; echo '<p id="trollRnd2">Track - </p>', "\n"; echo '<h4>Round 3</h4>', "\n"; echo '<p id="crollRnd3">Class - </p>', "\n"; echo '<p id="trollRnd3">Track - </p>', "\n"; echo '</body>'; echo '</html>';\[/code\]Again, any help is greatly appreciated.P.S. - Is it not working because the JavaScript is not JQuery? If so, how would I go about converting that to JQuery?
 
Back
Top