var formButtons = {};
$("#formtoload input[type=button]").each(function() {
$currentButton = $(this);
$currentButton.hide();
formButtons = $.extend({
$currentButton.value() : function(event, ui) {
$currentButton.click();
}
}, formButtons ||{});
});
// add a default close button since the form did not have one previously.
formButtons = $.extend({
"Close": function(event, ui) {
$(this).dialog('destroy').remove();
}
}, formButtons ||{});
// now show the dialog with formButtons passed in to
you can then do something like
$('#formtoload').dialog({
title: $('#formtoload').attr("title"),
modal: true,
position: 'top',
close: function(event, ui) { $(this).dialog('destroy').remove(); },
buttons: formButtons
});