lundi 7 mars 2016

How to access dynamically created div content using php

I have a form with div and a button. The div is editble with text as well as images. Now the problem is i am able to access the div contents (only text). But i need o access the div contents in terms of html. For example if the div content is having an image it should display . Here is the code what i tried so far. For retrieving the text content i am using the plugin PHP Simple HTML Dom version 1.5

if(isset($_POST['postreview']))
{
$html = file_get_html('index.php');
foreach($html->find('div#stage') as $e)
echo $e->innertext . '<br>';
}

where 'desc' div is used to display the editable div content in terms of html. in html body i have,

<div id = "stage" style = "background-color:cc0;">
     STAGE
  </div>
<div id="comment" name="comment"  onkeyup="getData();" class="boxed" contenteditable>
    This text is enclosed in a box.
    </div> 

and the Javascript for getData() is

function getData()
{
data1=$('#comment').html();
$.post("2.php",{content:data1},function(data){//alert(data);
 //display inserted msg with css
 $('#stage').text(data); //.html(data) for display in document purpose.
});
}

Now, as I type in comment div the respective text and image in tag will be displayed but, I need to assign the content available in 'stages' div to a php variable. All responses are welcome




Aucun commentaire:

Enregistrer un commentaire