1

We have a requirement where we need to get a snapshot of User filled in application. For this I have to get all HTML elements along with the User inputs and save the whole HTML for audit purpose. I am able to get the html by giving the

$("#divApplicationWrapper").html()

and I am able to get the inputs but using the serialize method

$("#frmApplication").serialize()

Is there a way to get both the HTML along with the values of the inputs?

Any help is much appreciated.

Thanks,

Raja

Raja
  • 3,608
  • 3
  • 28
  • 39
  • Whats wrong with wrapping the two above into a function? and doing whatever you want with the output? – benhowdle89 Feb 28 '11 at 15:17
  • Don't understand what you mean by wrapping the two? How to wrap it so that I could set the values of inputs into their respective controls? – Raja Feb 28 '11 at 15:22
  • I was trying out and wrote this which works in IE but not in FF :-(... $("input").each(function(){ var temp= $(this).val(); $(this).attr("value",temp); }); alert($("#divApplicationWrapper").html()); – Raja Feb 28 '11 at 16:22
  • Auditing is typically accomplished with an audit table in the database to clone changes made to the real table. Having the raw html is basically useless as it will change over time and there's no way to query it efficiently. Also different browsers will interpret the html differently and may even return varying html from the `.html()` method. Just saying... – Ryan Mar 01 '11 at 21:38
  • Thanks for the advise Ryan...We are already implementing audit tables in the database but the process here is to have a snapshot of the application (before this system they were scanning the actual application form and storing it). Customer is always right!!! – Raja Mar 02 '11 at 13:56

1 Answers1

0

The solution here helped me.

jQuery html() in Firefox (uses .innerHTML) ignores DOM changes

Hope this helps someone.

Thanks,

Raja

Community
  • 1
  • 1
Raja
  • 3,608
  • 3
  • 28
  • 39