Note that there are some explanatory texts on larger screens.

plurals
  1. POChanging fonts and values in html from javascript
    primarykey
    data
    text
    <p>I have a form in html and I want to change the text from 'champions league trivia' to 'Manchester' when I click the button. It changes cut only for a second and then changes back to 'champions league trivia'. I cant figure out why its changing back. Any ideas? </p> <pre><code>&lt;script type="text/javascript" src="quiz.js" &gt;&lt;/script&gt; &lt;body&gt; &lt;form action="" method="post" onsubmit="return checkscript()"&gt; &lt;h1&gt;Choose a Quiz&lt;/h1&gt; &lt;p&gt;&lt;input type="radio" name="Radio" value="1" /&gt;&lt;font size="5" color="#0033CC" id="cl"&gt;Champions League Trivia&lt;/font&gt;&lt;br /&gt; &lt;br /&gt; &lt;input type="radio" name="Radio" value="2" /&gt;&lt;font size="5" color="#CC0000" id="epl"&gt;English Premier League Trivia&lt;/font&gt;&lt;br /&gt; &lt;br /&gt; &lt;input type="radio" name="Radio" value="3" /&gt;&lt;font size="5" color="#660033" id="ll"&gt;La Liga Trivia&lt;/font&gt;&lt;br /&gt; &lt;br /&gt; &lt;input type="submit" name="Submit" value="Go" onclick="quizRun()" /&gt;&lt;/p&gt; &lt;/form&gt; &lt;p id="result"&gt;&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Here is the javascript</p> <pre><code>function quizRun() { var inputs = document.getElementsByTagName("input"); var choice = 0; if (inputs[0].checked) { choice = 1; var cl = document.getElementById('cl'); cl.textContent = 'Manchester'; } if (inputs[1].checked) { choice = 2; } if (inputs[2].checked) { choice = 3; } } function checkscript() { var inputs = document.getElementsByTagName("input"); for (var i=0, l=inputs.length; i&lt;l; i++) { if (inputs[i].name === "Radio" &amp;&amp; inputs[i].checked) return true; } return false; } </code></pre>
    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.
    1. This table or related slice is empty.
    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