kurayami
Technical User
- Mar 12, 2008
- 31
i have this script and I'm trying to make it work:
<head>
function go (){
var x, j, k;
x = document.getElementById('code').value;
j = ['1', '2', '3', '7', '8', '10'];
k = [ '4', '5', '6', '9'];
if (x == j) { document.getElementById('final').value = "A+"; }
if (x == k) { document.getElementById('final').value = "A-"; }
}
</head>
<input type = "text" id = "code" maxlength = 2 size = 2 />
<input type = "text" id = "final" maxlength = 2 size = 2 readonly = "readonly" />
<input type = "button" id = "code" maxlength = 2 size = 2 value = "go" onClick = "go();" />
What I am trying to do is that if user enters a number like 1-3,7-8, or 10 the 'final' field will show A+. If 4-6 or 9 then 'final' field will show A-. I cannot seem to get this to work if this is the script. I have tried using if..else and it does work, however, the data that I am working on has about 100+ codes.
"A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
-Douglas Adams
<head>
function go (){
var x, j, k;
x = document.getElementById('code').value;
j = ['1', '2', '3', '7', '8', '10'];
k = [ '4', '5', '6', '9'];
if (x == j) { document.getElementById('final').value = "A+"; }
if (x == k) { document.getElementById('final').value = "A-"; }
}
</head>
<input type = "text" id = "code" maxlength = 2 size = 2 />
<input type = "text" id = "final" maxlength = 2 size = 2 readonly = "readonly" />
<input type = "button" id = "code" maxlength = 2 size = 2 value = "go" onClick = "go();" />
What I am trying to do is that if user enters a number like 1-3,7-8, or 10 the 'final' field will show A+. If 4-6 or 9 then 'final' field will show A-. I cannot seem to get this to work if this is the script. I have tried using if..else and it does work, however, the data that I am working on has about 100+ codes.
"A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
-Douglas Adams