var macTeamList = "Team" + "<br>";
var macScoreList = "Score" + "<br>";
var nicTeamList = "Team" + "<br>";
var nicScoreList = "Score" + "<br>";
$('form').submit(function(e) {
if ($('input[name="Player1"]').val() ==="Nic") {
e.preventDefault();
var nicTeamValue = $('input[name="Team1"]').val();
nicTeamList += nicTeamValue + "<br>" ;
var nicScoreValue = $('input[name="Score1"]').val();
nicScoreList += nicScoreValue + "<br>";
$('#nicteamcolumn').html(nicTeamList);
$('#nicscorecolumn').html(nicScoreList);
return false;
}
else if ($('input[name="Player1"]').val() === "Mac") {
e.preventDefault();
var macTeamValue = $('input[name="Team1"]').val();
macTeamList += macTeamValue + "<br>" ;
var macScoreValue = $('input[name="Score1"]').val();
macScoreList += macScoreValue + "<br>";
$('#macteamcolumn').html(macTeamList);
$('#macscorecolumn').html(macScoreList);
return false;
}
})
<form>
<input name="foo" id="team" class="teamcolumn" type="text" value="Team?">
<input name="foobar" id="score" class="inputright" type="text" value="Score?">
<input type="submit" value="Go">
<select name="select" size="1" id="PID">
<option value="Nic">Nic</option>
<option value="Mac">Mac</option>
</select>
</form>
<div id ="nicteamcolumn" class="teamcolumn TOSRcolumn nicColumn">Team </div>
<div id="nicscorecolumn" class="scorecolumn TOSRcolumn nicColumn">Score</div>
<div id="macteamcolumn" class="teamcolumn TOSRcolumn macColumn">Team </div>
<div id="macscorecolumn" class="scorecolumn TOSRcolumn macColumn">Score</div>
Basically, I am having the user input 2 text values as well as choose from 2 options on a drop down menu. If the user chooses "Mac" the info in the two fields should print to #macscorecolumn and #macteamcolumnand vice versa if they choose "Nic". The list variables are keeping track of the whole list of scores so the new score is simply added to the end and they're all shown. Not sure why the script isnt working. Any help would be awesome