I’m using PHP, AJAX with jQuery so when this if statment process it will show all the players that have been selected along with placing a remove button and a onclick="removeplayer(test);". But when I click the “Remove player” button I will either get a null or undefined.
PHP
if(count($_SESSION['players'],COUNT_RECURSIVE) == $_SESSION['savedPlayers'] )
{
foreach($_SESSION['players'] as $key => $value){
echo "Player #: . $key . ; Player Name: . $value . \n";
echo "<input type=\"button\" name=\"" . $key . " \" id=\"" . $value . " \" value=\"Remove\" onclick=\"removePlayer(" . $value . ");\"> <br />";
}
echo "Max number of Players";
}
And my JavaScript is basic now because I’m just trying to make sure I’m getting the id passed correctly. I eventually will add jQuery that will remove the player from the list.
Here is my JavaScript:
function removePlayer(test){
alert(test);
};
Its because that you have not enclosed the $value within quotes try this