Reputation: 97
I have a modal dialogue with jquery which populate a div,I need instead of populate a div to submit directly ,How can I achieve that, What I did: I have a button when I click it opens a modal dialogue,with this modal dialogue I add data and I save data in another div,below the code:
My part of code :
<script>
$(function() {
$( "#MyDialog2" ).dialog({
autoOpen: false,
height: 300,
width: 700,
modal: true,
buttons: {
"ADD": function() {
$('#keyword_new_name').val($('#keyword_new_nameadd').val());
$( this ).dialog( "close" );
},
"Cancel": function() {
$( this ).dialog( "close" );
}
},
close: function() {
$('#keyword_new_nameadd').val("");
}
});
$( "#newKeyword" ).click(function() { $( "#MyDialog2" ).dialog( "open" ); });
});
</script>
HTML looks like that:
<div id='MyDialog2' >
<table cellpadding='11' >
<tr>
<td></td>
<td>Name:</td><td><input type='text' name ='keyword_new_nameadd' id='keyword_new_nameadd' size ='35' /></td>
</tr>
</table>
</div>
<form method="POST" action="">
<div>
<table cellpadding='11' >
<tr>
<td></td>
<td>Name:</td><td><input type='text' name ='keyword_new_name' id='keyword_new_name' size ='35' /></td>
</tr>
</table>
</div>
<input type='button' value='NewKeyword' id='newKeyword' />
<input type='submit' value='addKeyword' id='addKeyword' />
</form>
Thank you for your help!!!
Upvotes: 0
Views: 117
Reputation: 97
I got it I added
$( this ).dialog( "close" );
$("#add_keyword").click();
add_keyword is the ID of 1 of my submit buttons
Upvotes: 0
Reputation: 150108
If you mean that you want to directly submit your form, right after (or instead of... not sure which you need)
$('#keyword_new_name').val($('#keyword_new_nameadd').val());
add
$('form').submit();
Personally I would give the <form>
and ID and use that instead
$('#myFormId').submit();
Upvotes: 1