Not Adding Value To UL

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
CoolAsCarlito
Forum Contributor
Posts: 192
Joined: Sat May 31, 2008 3:27 pm
Contact:

Not Adding Value To UL

Post by CoolAsCarlito »

Nothing happens when the button is clicked to add a new character name to the UL.

This is in my ajax.js

Code: Select all

function WrestlerList()
{
var addWrestler = document.getElementById("character_selection").value
if (addWrestler) {
// Here we append a new wrestler to your hidden field using a comma
document.getElementById("chars").value += addWrestler+",";
// Continue your original functionality
document.getElementById("characterlist").innerHTML += "<li>" +
addWrestler + "</li>";
return WrestlerList;
}
}
backstagefunctions.php

Code: Select all

print '<script type="text/javascript" src="ajax.js"></script>';
   print '<h2 class="backstage">Characters<br /><br />';
   print '<select name="characterid" class="dropdown" id="character_selection">';
   print '<option value="">- Select -</option>';
   $query = 'SELECT charactername FROM characters';
   $result = mysql_query ( $query );
   while ( $row = mysql_fetch_assoc ( $result ) ) {
      print "<option value=\"".$row['charactername']."\">".$row['charactername']."</option>\r";
   }
   print '</select>&nbsp;&nbsp;<input type="hidden" id="chars" name="chars" value=""><input type="button" value="Add" onclick="WrestlerList()" class="button"></h2><br />';
   print '<ul id="characterlist"></ul><br /></form>';
Post Reply