I have a search form that can be built dynamically by the user using code such as:
$('tr.form_row:last').clone(true).insertAfter('tr.form_row:last');
All of this is working fine, however, I would like to save the dynamically generated form html when the form is submitted. I have tried using $(#my_form').html()
but this doesn't appear to have the dynamic content, instead, it's just the default html before customisation that is gathered.
Is there a way of getting the generated source using javascript/jquery? It would need to include the value within the input fields that the user has typed etc.
EDIT - I've included my coding so far:
This is the coding I have tried - it uses jquery form plugin and I populate a hidden form field called 'search_html':
var search_form = {
beforeSubmit: function() {
var search_html = '<table>';
$('.form_row').each(function() {
search_html += $(this).html();
});
search_html += '</table>';
$("#search_html").val(search_html);
},
success: function(html) {
$('#search_output').html(html);
}
};
$('#search_form').ajaxForm(search_form);
When I submit the form, HTML is passed within the hidden 'search_html' field, but it is only the first table row and doesn't have the values of the input fields populated.