Note that there are some explanatory texts on larger screens.

plurals
  1. POFunction is not Called
    primarykey
    data
    text
    <p>I have some javascript that is supposed to run after the window loads but for some reason, it never runs.</p> <p>Here's my code:</p> <pre><code>function setClasses(){ document.getElementsByClassName("gchoice_35_0")[0].onclick = sedanShow; document.getElementsByClassName("gchoice_22_0")[0].onclick = sedanShow; document.getElementsByClassName("gchoice_34_0")[0].onclick = sedanShow; document.getElementsByClassName("gchoice_34_1")[0].onclick = suvShow; document.getElementsByClassName("gchoice_35_1")[0].onclick = suvShow; document.getElementsByClassName("gchoice_22_1")[0].onclick = suvShow; document.getElementsByClassName("gchoice_22_2")[0].onclick = vanShow; document.getElementsByClassName("gchoice_35_2")[0].onclick = vanShow; document.getElementsByClassName("gchoice_34_2")[0].onclick = vanShow; } window.onload = setClasses; </code></pre> <p>The setClasses() function doesn't seem to run. It does however work when I manually call it through the console of FireBug.</p> <p>The code is placed in the header of my web page.</p> <p>Any help is appreciated.</p> <p>Full html snippet:</p> <pre><code>&lt;head&gt; ...... &lt;script type="text/javascript"&gt; function setClasses(){ document.getElementsByClassName("gchoice_35_0")[0].onclick = sedanShow; document.getElementsByClassName("gchoice_22_0")[0].onclick = sedanShow; document.getElementsByClassName("gchoice_34_0")[0].onclick = sedanShow; document.getElementsByClassName("gchoice_34_1")[0].onclick = suvShow; document.getElementsByClassName("gchoice_35_1")[0].onclick = suvShow; document.getElementsByClassName("gchoice_22_1")[0].onclick = suvShow; document.getElementsByClassName("gchoice_22_2")[0].onclick = vanShow; document.getElementsByClassName("gchoice_35_2")[0].onclick = vanShow; document.getElementsByClassName("gchoice_34_2")[0].onclick = vanShow; } function sedanShow(){ document.getElementById("sedan").style.display="inline" document.getElementById("suv").style.display="none" document.getElementById("van").style.display="none" } function suvShow(){ document.getElementById("sedan").style.display="none" document.getElementById("suv").style.display="inline" document.getElementById("van").style.display="none" } function vanShow(){ document.getElementById("sedan").style.display="none" document.getElementById("suv").style.display="none" document.getElementById("van").style.display="inline" } window.onload = setClasses; &lt;/script&gt; </code></pre> <p>...... </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload