Sicton
08-21-2004, 09:04 PM
Right, this has had me stumped for ages so I just had to ask on these forums. I'm trying to parse a variable from an editable DIV into php so it can process the variable as opposed to using just a textarea. The code I've got so far which doesn't work is as below.
<!-- Simple example of the PHP usage -->
<?php
if($_POST['postvar'] == '1'){
echo $_POST['divEditable'];
}
?>
<script language="javascript">
function getDiv() {
document.myForm.hiddenField.value = document.getElementById('divEditable').innerHTML;
return true;
}
</script>
<form action="" method="post">
<div id="divEditable" contenteditable="true" style="background: #F2F2F2"></div>
<input type="hidden" name="postvar" value="1">
<input type="submit" name="submit" value="Submit" onClick="getDiv();">
</form>
Any help would be grately appreciated. Sorry if this should be in the PHP section, it's just it seems to me it's in need more of javascript expertise.
<!-- Simple example of the PHP usage -->
<?php
if($_POST['postvar'] == '1'){
echo $_POST['divEditable'];
}
?>
<script language="javascript">
function getDiv() {
document.myForm.hiddenField.value = document.getElementById('divEditable').innerHTML;
return true;
}
</script>
<form action="" method="post">
<div id="divEditable" contenteditable="true" style="background: #F2F2F2"></div>
<input type="hidden" name="postvar" value="1">
<input type="submit" name="submit" value="Submit" onClick="getDiv();">
</form>
Any help would be grately appreciated. Sorry if this should be in the PHP section, it's just it seems to me it's in need more of javascript expertise.