未捕获的ReferenceError:未定义IDSelectionner

I get following error on my onclick function : "Uncaught ReferenceError: IDSelectionner is not defined". I call the function in the echo. Am I missing anything related to the table that I'm not aware or is my issue else where?

Here's the code for that part:

<?php require_once('connect.php');?>

<script type="text/javascript">
    var typeDroitIDSelectionne = 1;
</script>

<table>
    <tr>
        <td>
            <div id="titreTableau">
                <label>Type de droit</label>
            </div>
        </td>
    </tr>
        <?php

            $stmt = $db->prepare('SELECT * FROM typeDroits');
            $stmt->execute() or die(var_dump($stmt->errorInfo()));
            $result = $stmt->fetchAll();

            foreach ($result as $row) {
            $typeDroitID = $row['type_droit_ID'];
            $typeDroitDesc = $row['type_droit_description'];
            echo("<tr><td>
            <label id='".$typeDroitID."' onclick='IDSelectionner(this.id)'>".$typeDroitDesc."</label>
            </td></tr>");

            }

            ?>
 </table>
<script type="text/javascript">
function IDSelectionner (elem) {
        alert(elem);
        typeDroitIDSelectionne = elem;
    }

The error wasn't in the calling the function part. It was in another section of my code where I miswrote a name of a file.