I'm using jquery to open a dialog containing an iframe (don't ask!). I want to submit the form in the iframe on closing the dialog but it isn't working.
I'm probably making a simple error (I'm quite new to jquery) but this problem has been driving me round the bend.
Here is my code:
$(function() {
$( "#iframe" ).dialog({
modal: true,
autoOpen: false,
height: 500,
width: 700,
buttons: {
"Save and close": function() {
$( "#iframe").contents().find("#contentform").submit();
$( "#iframe" ).dialog( "close" );
},
Cancel: function() {
$( "#iframe" ).dialog( "close" );
}
}
});
$( "#openProfile" ).click(function() {
$( "#iframe" ).dialog( "open" );
$('#iframe').attr('src','file.asp');
return false;
});
});
However, if I do this instead of submitting the form:
"Save and close": function() {
var myformvalue = $( "#iframe").contents().find("#formfield").val();
alert(myformvalue);
$( "#iframe" ).dialog( "close" );
}
...it returns the correct value so I know it is recognising my form and its values.
Thanks in advance for your help.
iframein a different domain from the parent page?"Save and close"callback, if you do aconsole.log($( "#iframe").contents().find("#contentform").length);what gets logged?<form name="contentform" id="contentform" action="myfile2.asp?pid=<%=pid%>&cid=<%=cid%>&update=1" method="post" enctype="multipart/form-data"> <textarea id="myTextArea" name="myTextArea" style="height:250px;"> <%=sContent%> </textarea> <input type="hidden" name="eid" id="eid" value="<%=eid%>"> <input type="hidden" name="delimg" id="delimg" value=""> </form>