As the title says I'm trying to append some text to a textarea in html, but the result always has some strange text involving NaN appearing in the textarea... Here is my code:
  <!DOCTYPE html>
  <html>
  <head>
  </head>
  <body>
  <?php 
     $_SESSION['currentlocation'] = "combat.php"; 
     ?>
     <script type="text/javascript">
            if(document.getElementById("wrapper") == null) {
              window.location = "../index.php";    
           }
       </script>
<textarea id="combatinfo" rows="4" cols="50"></textarea>
<br />   
<?php
$_SESSION['currentlocation'] = "combat.php";
if($_SESSION['ambush'] && $_SESSION['flee']) {
    for($i = 0; $i < sizeOf($_SESSION['enemies']); $i++) {
        echo $_SESSION['enemies'][$i]->rank;
        $scaling = 20 - $_SESSION['enemies'][$i] -> luck;
        if($_SESSION['enemies'][$i]-> rank >= 20 && $_SESSION['enemies'][$i]-> rank < 40) {
            $prob = rand(1, 100);
            if($prob <= 100) {              
       //                if($prob <= 75 - $scaling * 3.8) {
                if($_SESSION['comboAttack'] < 2) {
                    $_SESSION['comboAttack'] = 2;
                }
                $_SESSION['enemies'][$i]->comboAttack = 2;
              ?>                  
                <script type="text/javascript">
                    $(document).ready(function() {
                         $('#combatinfo').append("HELLO WORLD!");
                    });
                </script>    
        <?php        
            }
        }
        else if($_SESSION['enemies'][i]-> rank >= 40 && $_SESSION['enemies'][i]-> rank < 60) {
            $prob = rand(1, 100);
            if($prob <= 50 - $scaling * 3.8) {
                if($_SESSION['comboAttack'] < 3) {
                    $_SESSION['comboAttack'] = 3;
                }
                $_SESSION['enemies'][i]->comboAttack = 3;
               ?>                    
                <script type="text/javascript">
                    $(document).ready(function() {
                        var str1 = "Enemy ";
                        var str2 = "pulls off a 3-hit combo.\n";
                        var str = str1.concat(str2);
                        $('#combatinfo').append("HELLO WORLD!");
                    });
                </script>
           <?php
            }
            else if($prob <= 75 - $scaling * 3.8) {
                if($_SESSION['comboAttack'] < 2) {
                    $_SESSION['comboAttack'] = 2;
                }
                $_SESSION['enemies'][i]->comboAttack = 2;
           ?>
                <script type="text/javascript">
                    $(document).ready(function() {  
                        var str1 = "Enemy ";
                        var str2 = "pulls off a 2-hit combo.\n";
                        var str = str1.concat(str2);
                        $('#combatinfo').append("HELLO WORLD!");
                    });
                </script>
     <?php                        
            }
        }
        $_SESSION['enemies'][$i] ->attack($i);
    }
 ?>
<button type="button">Defend</button> <button type="button">Flee</button>
<form action="index.php" method="post">
<input type="submit" name="submit" value="Submit" />
</form>
<?php           
}
else if(ambush && !flee) {
?>        
<button type="button">Defend</button> <button type="button">Flee</button> 
<?php
}
if(!ambush && flee) {
?>        
<button type="button">Attack</button> <button type="button">Flee</button>
<?php
}
else if(!ambush && !flee) {
?>        
<button type="button">Defend</button> <button type="button">Flee</button>
<?php     
}
?>
<br />
<select id="selectClone">        
<?php
if(sizeOf($_SESSION['playercharacter'] -> clones) == 0) {
?>
    <script type="text/javascript">
        $(document).ready(function() {
            var dropDownMenu = document.getElementById("selectClone");
            dropDownMenu.disabled = true;
        });
    </script>             
    <option value="Player">Player</option>
<?php        
}
else if(sizeOf($_SESSION['playercharacter'] -> clones) == 1) {
?>
    <option value="Clone 1">Clone 1</option>              
<?php
}
?>            
</select>
<div id="player" class="group">asdf</div>
<div id="clone1" class="group">dsfdsfds</div>    
<script type="text/javascript">
    $(document).ready(function() {
        $('.group').hide();
        $('#player').show();
        $('#selectClone').change(function () {
            $('.group').hide();
            $('#'+$(this).val()).show();
        })
    });
</script>
for some reason in the textarea i get the text "Enemy #NaN" appended onto the text I want. Why is this happening, and how do i stop it from happening?