trying to get onclick to call a Java script more than once
First of all my apologies if there is a very obvious answer to this but I
have searched extensively to try and find an answer. I am very new to Java
script and am really struggling with this problem. I have a form which
asks if you stay at another address if you click yes an address block open
and you can fill in an other address. under that block you are asked if
you want to add a further address if you click yes then I would like
another address block to open exactly the same as the first but I get
nothing. I am assuming the reason for this is because the JS function has
already activated once and will not do so again unless I can give it some
means of counting the number of times it has opened or needs to open. I
have copied the functioning part of my code below can anyone point out
clearly and concisely where I have gone wrong, please bear in mind that my
understanding of JS is very limited so an idiot guide would be
appreciated. my code:
<div id=content>
<!-- QUESTION TEXT GOES HERE -->
<h3><span class="QID">8</span>Do you stay at another address, other than
your current address, for more than 30 days a year?</h3>
<form>
<p></p>
<input type="radio" name="Text">No <a href="PCS_p10.htm">Go to Question 10
</a><br>
<p></br></p>
</form>
<form>
<p></p>
<script type="text/javascript">
function checkIt(el) {
var elArr = ['mtext',];
for (var i=0; i<elArr.length; i++) {
sel = document.getElementById(elArr[i]);
if (el.value == elArr[i]) { sel.style.display = 'block'; }
else { sel.style.display = 'none'; }
}
}
</script>
</head>
<body>
<input type="radio" name="radioBtn" value="mtext"
onclick="checkIt(this)">Yes
<div id="mtext" style="display:none;width" />
<input type="text" id="multiple1" size="60" name="text"><br>
<input type="text" id="multiple2" size="60" name="text"><br>
<input type="text" id="multiple3" size="60" name="text"><br>
<input type="text" id="multiple4" size="60" name="text"><br>
<pre><font face="arial,helvetica" size"+1">
Postcode <input type="text"
id="multiple5" name="postc1" style="width: 40px;" maxlength="4">
<input type="text" name="postc2" style="width: 40px;"
maxlength="4"></pre><br>
Add another address
<input type="radio" name="radioBtn" value="mtext"
onclick="checkIt(this)">Yes
<input type="radio" name="Text">No <a href="PCS_p10.htm">Go to
Question 10 </a><br>
</div>
</body>
</html>
<p></br></p>
</form>
No comments:
Post a Comment