I want to be able to select from a list of buttons and this display to the screen the value of that button. I have a function but im not sure what parameters to have within the HTML or function.
<input type="button" class="button" id="button2" value="2" onclick="click(this)">
<input type="button" class="button" id="button3" value="3" onclick="click(this)">
<input type="button" class="button" id="button4" value="4" onclick="click(this)">
function click(button){
var buttonclicked = document.getElementById(button.id).value;
firstbox.innerHTML = "Your Chosen button is: " + buttonclicked;
button.disabled = true;
}
Aucun commentaire:
Enregistrer un commentaire