I am trying to allow a user to select a font from a dropdown list that will change the fontFamily applied to text they've entered in a form text field. I've tried several variations on the following, with no success on Safari or Chrome. I'd appreciate it if someone can point out what I'm doing wrong. Changing colors works. Changing the fontFamily does not.
<html>
<head>
<script>
function setPreview()
{
var myColor = document.getElementById("selectedColor").value;
document.getElementById("inputText").style.color = myColor;
var myFont = document.getElementById("selectedFont").value;
document.getElementByID("inputText").style.fontFamily = myFont;
}
</script>
</head>
<body>
<form>
<label for="uname">Enter Text: </label>
<input type="text" id="inputText" name="name" placeholder="YourName" maxlength="8">
<select name="textColor" id="selectedColor" onchange="setPreview();">
<option value="black" selected="selected">Black</option>
<option value="red">Red</option>
</select>
<select name="textFont" id="selectedFont" onchange="setPreview();">
<option value="Arial" selected="selected">Arial</option>
<option value="Impact">Impact</option>
<option value="Times New Roman">Times New Roman</option>
</select>
</form>
</body>
</html>