I have the following script:
<script type= 'text/javascript'>
function displayPlayer() {
var input = document.getElementById("player_stuff").elements;
var position = input[0];
var player_id = input[1];
document.getElementById('disp_player').innerHTML = position + player_id
}
</script>
And a simple HTML form:
<form id = 'player_stuff' onsubmit = 'displayPlayer()'>
Player's Position:<br>
<input type="radio" name="position" value="p1" checked>Position One
<input type="radio" name="position" value="p2" checked>Position Two
<input type="radio" name="position" value="p3" checked>Position Three
<input type="radio" name="position" value="p4" checked>Positin Four
<br/>
Add by Player ID:<br>
<input type='text' name='player_id'>
<input type="submit" value="Submit Player" id='smit' >
</form>
<div id = 'roster'>
<h3>Current Roster</h3>
<p id= 'disp_player'></p>
</div>
The idea is that when I click on the Submit Player button, it will trigger the displayPlayer() function and add the position name and player ID to the
<p id= 'disp_player'></p>
tag.
What am I doing wrong, since nothing is showing up?