I have this code that allows me to send 12 numbers to 12 different text boxes. It doesn’t show any number that is 1.
[CODE]
<html>
<head>
<title>TBox Filler</title>
<!– script type=”text/javascript”>External file of numbers to be added later</script –>
<script type=”text/javascript”>
function Setup() {
var inStr = document.getElementById(‘testTxt’).value;
if (inStr.length < 12) { alert(‘Test number too short’); return; }
var ch = ”;
for (var i=0; i<12; i++) {
ch = inStr.charAt(i);
if (ch == ‘1’) { document.getElementById(‘N’+i).value = ”; }
else { document.getElementById(‘N’+i).value = ch; }
}
}
</script>
</head>
<body>
Test input (12 numbers [1..9]):<br><input type=”text” id=”testTxt” value=”134439483111″>
<p>
<input type=”text” size=”2″ value=”” id=”N0″>
<input type=”text” size=”2″ value=”” id=”N1″>
<input type=”text” size=”2″ value=”” id=”N2″>
<input type=”text” size=”2″ value=”” id=”N3″><br>
<input type=”text” size=”2″ value=”” id=”N4″>
<input type=”text” size=”2″ value=”” id=”N5″>
<input type=”text” size=”2″ value=”” id=”N6″>
<input type=”text” size=”2″ value=”” id=”N7″><br>
<input type=”text” size=”2″ value=”” id=”N8″>
<input type=”text” size=”2″ value=”” id=”N9″>
<input type=”text” size=”2″ value=”” id=”N10″>
<input type=”text” size=”2″ value=”” id=”N11″><p>
<button onclick=”Setup()”>Initialize</button>
</body>
</html>
That code works perfectly.
So currently I have one set of numbers: 134439483111
However, this will come out as “”,3,4,4,3,9,4,8,3,””,””,””
What I would like is if there was a second set of numbers where instead of 1 the correct number would be entered e.g. 734439483354
I want a button so that when the user clicks it, it checks to see if where the first number should be a 7 if it is. If they have entered a 4 where the blank space should be a 7 then the 4 would turn red, if they entered a 7 it would turn green.
I am stumped as how to do this, maybe some if else statement in the function ?
Any help would be greatly appreciated! Thank you for taking the time to read this ?