...

View Full Version : Get value of input field from JQuery modal window



EmmaC
12-12-2010, 12:48 PM
Hi,

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>
<div>
<input id="enteredName" name="enteredName" type="text" value="" />
<a href="javascript:submitform(true)" name="save" id="save" class="btn"><span>Save</span></a>
</div>
<a href="javascript:submitform(false)" id="close" class="close-link">No thanks just carry on</a>
</div>


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");
form.submit();

}


</script>


Any help would be much appreciated.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum