<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
var redtoggle=false;
function togglered()
{
redtoggle = !redtoggle;
if (redtoggle)
{
document.getElementById("txtInput").style.color = "red";
}
else
{
document.getElementById("txtInput").style.color = "black";
}
}
var bluetoggle=false;
function toggleblue()
{
bluetoggle = !bluetoggle;
if (bluetoggle)
{
document.getElementById("txtInput").style.color = "blue";
}
else
{
document.getElementById("txtInput").style.color = "black";
}
}
var greentoggle=false;
function togglered()
{
greentoggle = !greentoggle;
if (greentoggle)
{
document.getElementById("txtInput").style.color = "green";
}
else
{
document.getElementById("txtInput").style.color = "black";
}
}
</script>
<select id="dropdown">
<button onclick="myFunction()" class="dropbtn">color change</button>
<div id="myDropdown" class="dropdown-content">
<option id="disabledselected" >color change</option>
<option id="btnTogglered" onclick="togglered()">red</option>
<option id="btnToggleblue" onclick="toggleblue()">blue</option>
<option id="btnTogglegreen" onclick="togglegreen()">green</option>
</div>
</div>
<form>
<div>
TEXT INPUT
<br>
<input type="text" name="txtInput" id="txtInput">
</div>
</form>
</body>
</html>
So I'm making a word possessor and I've run into a problem where I can't change the color of the text, I've also added a way to change the text format but that all works and I need a little help with changing the color of the text. If anyone would be willing to help me and tell me where I've gone wrong.