Hack, hack, hack, hack hack ... Without suggesting “do not use the constructor of forms”, I don’t think there is an elegant solution - you cannot use the other suggested PHP method without changing the plugin (and it can be a worm). I suggest a Javascript solution, but there are some caveats (below):
jQuery(document).ready(function($){ $('#quick-quote form:first').submit(function(){ var foo = {}; $(this).find('input[type=text], select').each(function(){ foo[$(this).attr('name')] = $(this).val(); }); document.cookie = 'formData='+JSON.stringify(foo); }); var ff = $('#container form:first'); if(ff.length){ var data = $.parseJSON( document.cookie.match('(^|;) ?formData=([^;]*)(;|$)')[2] ); if(data){ for(var name in data){ ff.find('input[name='+name+'], select[name='+name+']').val(data[name]); } } } });
Basically it will be: when sending, save the mini-form parameters in a cookie . When the page loads, it will search for the form in the main part of the page and apply any stored cookie data.
Notes
- JQuery selectors are intentionally ambiguous in order to avoid any future changes in your admin panel / plugin that are likely to be screwed with form identifiers (thus violating the script).
- I'm not talking about field / option field names - for example, the selection field in the mini-form is called
insurance-type , however the correspondence field in the main form is called ins-type - which you will have so that they have the same name . - This also applies to the values of the selection fields - if there is no corresponding value, it will be ignored (for example, some of your values in the main form have & raquo;
» characters in front (and therefore do not match).
Emissary
source share