I have a JQuery modal window and I am trying to pass the value of its input field to a hidden input field within a form but I can not seem to get the value when it is in the modal window.

Modal Window Code:
<div id="modal-content" class="clearfix">

<h2> enter a name</h2>
		<input id="enteredName" name="enteredName" type="text" value="" />
		<a href="javascript:submitform(true)" name="save" id="save" class="btn"><span>Save</span></a>
	<a href="javascript:submitform(false)" id="close" class="close-link">No thanks just carry on</a>
Javascript to set the value of the hidden field to equal the value of the modal input field
<script type="text/javascript">
    function submitform(assignName) {
        if (assignName) {

            var hiddenfield = document.getElementById("hiddenfieldid");
            hiddenfield.value = document.getElementById("enteredName").value;

        var form = document.getElementById("formTest");

Any help would be much appreciated.