_user
February 22nd, 2013, 12:59 PM
<script type="text/javascript">
function replace1() {
document.getElementById('number').innerHTML = "<b>2:</b>";
document.getElementById('question').innerHTML = "<b>ABC </b>";
document.getElementById('answer1').innerHTML = "<input type=\"radio\" name=\"radio\" id=\"radio\" value=\"radio\" /> Yes";
document.getElementById('answer2').innerHTML = "<input type=\"radio\" name=\"radio\" id=\"radio\" value=\"radio\" /> No";
document.getElementById('nextbutton').innerHTML = "<a href=\"javascript:replace2()\">Next Question ></a>";
}
function replace2() {
document.getElementById('number').innerHTML = "<b>3. </b>";
document.getElementById('question').innerHTML = "<b>DEF </b>";
document.getElementById('answer1').innerHTML = "<input type=\"radio\" name=\"radio\" id=\"radio\" value=\"radio\" /> Yes";
document.getElementById('answer2').innerHTML = "<input type=\"radio\" name=\"radio\" id=\"radio\" value=\"radio\" /> No";
document.getElementById('nextbutton').innerHTML = "<a href=\"javascript:replace3()\">Next Question ></a>";
}
</script>
<div class="questionnaire">
<span id="number"><strong>1.</strong></span>
<span id="question"><strong>123</strong></span>
<p><span id="answer1"><input name="radio" id="radio" value="radio" type="radio" />Yes</span><br />
<span id="answer2"><input name="radio" id="radio" value="radio" type="radio" />No</span></p>
<div id="nextbutton"><a href="javascript:replace1()">Next</a></div></div>
Problem: I'm trying to use javascript replace to change the question on a webpage when the user hits 'Next'. At the moment when the user hits 'Next' nothing happens. Gedit syntax highlighting also suggests there is a problem with my javascript but I can't see where the issue is. I'm aware "javascript:replace3()" won't actually do anything - I've just simplified the code whilst troubleshooting it.
function replace1() {
document.getElementById('number').innerHTML = "<b>2:</b>";
document.getElementById('question').innerHTML = "<b>ABC </b>";
document.getElementById('answer1').innerHTML = "<input type=\"radio\" name=\"radio\" id=\"radio\" value=\"radio\" /> Yes";
document.getElementById('answer2').innerHTML = "<input type=\"radio\" name=\"radio\" id=\"radio\" value=\"radio\" /> No";
document.getElementById('nextbutton').innerHTML = "<a href=\"javascript:replace2()\">Next Question ></a>";
}
function replace2() {
document.getElementById('number').innerHTML = "<b>3. </b>";
document.getElementById('question').innerHTML = "<b>DEF </b>";
document.getElementById('answer1').innerHTML = "<input type=\"radio\" name=\"radio\" id=\"radio\" value=\"radio\" /> Yes";
document.getElementById('answer2').innerHTML = "<input type=\"radio\" name=\"radio\" id=\"radio\" value=\"radio\" /> No";
document.getElementById('nextbutton').innerHTML = "<a href=\"javascript:replace3()\">Next Question ></a>";
}
</script>
<div class="questionnaire">
<span id="number"><strong>1.</strong></span>
<span id="question"><strong>123</strong></span>
<p><span id="answer1"><input name="radio" id="radio" value="radio" type="radio" />Yes</span><br />
<span id="answer2"><input name="radio" id="radio" value="radio" type="radio" />No</span></p>
<div id="nextbutton"><a href="javascript:replace1()">Next</a></div></div>
Problem: I'm trying to use javascript replace to change the question on a webpage when the user hits 'Next'. At the moment when the user hits 'Next' nothing happens. Gedit syntax highlighting also suggests there is a problem with my javascript but I can't see where the issue is. I'm aware "javascript:replace3()" won't actually do anything - I've just simplified the code whilst troubleshooting it.