tags:

views:

28

answers:

1

Hello,

I have a page that contains a table that the user can update. This has been done using javascript.

When the user has finised updating, I want to have the raw HTML page uploaded to the server, and then the user will be redirected to a php page which will do some final processing and spit out a report.

Is this possible or should I come up with another method of reaching the same end... and if so how do I get the dynamically created HTML onto the server to be manipulated?

+1  A: 

You could have a form with a hidden input, and load the html into it using jquery.

So, your html may look like this:

<table id="table1">
  ... (this is the table from which you want to get the html)
</table>
<form id="form1">
  <input type="hidden" id="table_html" name="table_html" />
  <input type="submit" value="Submit" />
</form>
<script>
  $("#form1").submit(function() {
    $("#table_html").val($("#table1").html());
  });
</script>

I didn't test this or anything, but the idea is that when you submit the form, the script populates the hidden value with the table html.

Now, if you have complex stuff in the table (I assume you do since the user can edit stuff right there), then maybe sending all the html isn't the best thing, you'll get a lot of garbage with the "useful" stuff. The way I'd do it is have the table inside the form, and have everything in inputs. Probably the names of the inputs will be like "first_name[]", so php will get arrays of values when there are several rows with the same cells and stuff like that.

cambraca