function Play() {
var option = ["Rock", "Paper", "Scissors"];
var randomOption = option[Math.floor(Math.random()*option.length)];
console.log(randomOption)
var UserOption = document.getElementById('UserSelect');
console.log(UserOption);
}
Play();
<div class="form-group">
<select class="form-control" id="UserSelect">
<option value="1">Rock</option>
<option value="2">Paper</option>
<option value="3">Scissors</option>
</select>
</div>
I'm trying to save the selected option in UserOption. I can't seem to figure out what I am doing wrong.
Play()function ? I can not see this function being called anywhere in your codevalueattributes to be the actual string you want instead of a number, eg<option value="Rock">Rock</option>then you can simply usedocument.getElementById("UserSelect").value