I'm making an Front-End ui design. And i want to echo a selected font name. I used a tag, with in there multiple tags, with values bound to them. I want the value of the selected option to be echo'd using innerHTML Can someone help me with this problem? thanks in advance! Html code:
function EchoFontName() {
var x = document.getElementById("FontSelect").selectedIndex;
var f = document.getElementById("FontName");
var FontNameVar = document.getElementsByTagName("option")[x].value;
f.innerHTML = FontNameVar;
}
<div id="MainContainer">
<div id="Left">
<p id="FontSettings">Font settings</p>
<p id="Font">Ab</p>
<p id="FontName">
<span id="FontWeight"> </span>
</p>
</div>
<div id="Right">
<select id="FontSelect" onchange="changeFont(this);">
<option value="roboto">Roboto</option>
<option value="lato">Lato</option>
<option value="raleway">Raleway</option>
<option value="ubuntu">Ubuntu</option>
</select>
</div>
</div>
I already got the font change script working so don't worry about that! :)