0

I am trying to copy or extract a section of a web page which has a form with values into a variable So that I can print that section from there? I tried jquery html() but it only seems to get the markup. and clone() is an object which can only be pasted into a jquery DOM object. I am trying to get it into a hidden variable which will be posted to the server and send back down into ViewBag to be printed on this second page? Any ideas how to accomplish this?

Manuel Valle
  • 297
  • 8
  • 18
  • 1
    I think this is a duplicate question, see [*How to print part of a rendered page rendered html page*](http://stackoverflow.com/questions/1071962/how-to-print-part-of-rendered-html-page-in-javascript), although realistically you could just reuse the form template on your server and resend it with relevant stylesheet(s) and print it from there using what's in the answer on that question I linked. – Jared Farrish Jun 30 '12 at 21:47
  • that works if there are no input elements. IF there are input elements the form is printed without values..innerHTML does not pick for values, only if you post back to same page then innerHTML will pick up the form values....that is my problem...I dont want to make the user to post back.....he wont understand... – Manuel Valle Jun 30 '12 at 22:00
  • Why is it imperative to print *the form with input elements and values*? Also, if you have your site modularized, you could resend the form template back with the same form in a different "view". Nonetheless, you might be able to use a Javascript PDF script to print and send it to the server, and send it back? Or submit with AJAX. There's any number of ways to work this, the least best being saving the DOM contents and resending to a landing page. My opinion: Make a print view with regular markup. Ditch the "form literal" view on roundtrip. – Jared Farrish Jun 30 '12 at 22:06
  • I wanted to do as easy as possible. I think i will post back with the view populated and 2 buttons. "print", "confirm". thanks. I will also search on printing a javascript PDF this looks tempting. – Manuel Valle Jun 30 '12 at 22:16
  • I still have a question about this scenario. Why the value="name" of an input is only available on the markup when the form is posted back and not when the form is first rendered empty and edited? I think there has to e an explanation for that....could anyone help? – Manuel Valle Jul 01 '12 at 01:15

0 Answers0