Hi all, I wonder if anyone could help me.
I am trying to create a script for a website.
Customers will enter dimensions in CM and when they click on the button the answers “yes” or “no” will appear in columns against questions such as “Is measurement A more than 60cm” etc etc.
I have managed to get the numbers to work fine but I am stuck on the following…
1) If a customer accidently puts in a letter rather than a number I would like the answer to be “error”
2) If the answer is “yes” I would like the background (where the yes and no appear) to be Green and if the answer is “no” I would like the background to be red.
You can see the table I am working on here… [url]http://tinyurl.com/jmd2zrz
The script that I am using is as follows…
<script>
function standard1() {
var number = document.getElementById(“myInput”).value;
var letter = document.getElementById(“myInput”).value;
var text;
var text;
// If the letter is “c”
if (number < “56”) {
text = “yes”;
// If the letter is “c” or “e”
} else if (number === “56” || number > “56” || letter === “x”) {
text = “no”;
// If the letter is anything else
} else {
text = “error”;
}
document.getElementById(“standarda1”).innerHTML = text;
}
</script>
You can see that I am adding the letter “x” to try and get “no” but I get “no” for every letter I enter, rather than just “x” where every other letter should be “error”. The background colour, ie filling the table cell with the colour red or green is beyond me I am afraid.
I would be grateful if anyone could give a pointer here, I’m sure I am close but presently no cigar!… many thanks in advance : Dom