If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

<?php
//Set this variable so we can avoid and issues with unset vars
$postedDiv = "";
//Chek to see if the field was submitted.
if(isset($_POST['divData'])){
//If it was, lets set a variable to it.
$postedDiv = "You saved:" . $_POST['divData'];
}
?><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><!--Import jQuery--><script language="javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js" type="text/javascript"></script><!-- Setting of Char Encoding--><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><!--You better know what this is--><title>Test</title><script type="text/javascript">
//Make sure we wait until the page
$(document).ready(function(){
//Binds the save button to a click action
$("#saveBtn").click(function(){
//Get the content of the div with id "useData"
data = $("#useData").html();
//Set the value of the hidden field
$("#useDataField").val(data);
//Submit form that has id someForm
$("#someForm").submit();
});
});
</script><style type="text/css">
/*I am not explaining this, you better know it*/
#hiddenFormWrap{
display: none;
}
</style></head><body><!--The div with the content we want to save--><div id="useData">
Some Data in a Div
</div><!--A button that triggers the form submit--><input type="button" id="saveBtn" value="Save Div" /><!--This echos the result of your post. If it is the initial load, it is blank--><div><?php echo $postedDiv; ?></div><!--this contains the form that is hidden. You dont need the form to be hidden, I just did for this example--><div id="hiddenFormWrap"><!--We need this so we can easily submit the data--><form id="someForm" method="post"><!--A hidden form that is responsible for submitting the content of the div--><input type="hidden" name="divData" id="useDataField" /></form></div></body></html>