Hello, just having a little trouble with the use of the toLowerCase() function. My project is to edit text in a text area. I have a basic change colour function which gets the user to put either red, blue, green or yellow into it to a
textbox. It usessome if statements, which was working fine until I added the toLowerCase() function. Here is my
code.

for JavaScript:

function changeColour() {
var color = document.forms["myForm2"]["myTextBox"].value;
colour = color.toLowerCase();
if(colour == "red") {
document.myForm1.myTextArea.style.color ="red";
} else if (colour == "blue") {
document.myForm1.myTextArea.style.color ="blue";
} else if (colour == "green") {
document.myForm1.myTextArea.style.color ="green";
} else if (colour == "yellow") {
document.myForm1.myTextArea.style.color ="yellow";
} else { alert("Please enter red, blue green or yellow")
}

for the html:


<script type="text/javascript" src="functionsJS.js">
</script>
<form name="myForm1">
<textarea rows="4" cols="50" id="myTextArea" name="myTextArea">
</textarea>
</form>

<form name="myForm2">
Colour:<input type="text" name="myTextBox" value="red, blue, green or yellow.">
</form>
<button onclick="changeColour()">Change Colour</button>