/    Sign up×
Community /Pin to ProfileBookmark

Checking a set of numbers against another

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>
[/CODE]

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 ?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@tv_boy123authorApr 22.2009 — Anyone have any ideas how I would do this? Any pointers or guidance would be appreciated ? thanks.
×

Success!

Help @tv_boy123 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...