Div with contentEditable doesn't fit in form using Javascript
Okay, so I have this div:
// DESCRIPTION AREA
$body_html .= "<div id='seq-desc-".$seq_id_d."' contenteditable='true' data-text='Det som skal skje...'>";
$body_html .= $seq_desc_d;
$body_html .= "</div> ";
and this is a text box:
$body_html .= "<textarea id='seq-desc-area-".$seq_id_d."' name='deta-".$seq_id_d."' style='display: none;'></textarea></td>";
In my form, I use the following code to activate my JavaScript code:
"<form action='planner_seq_save.php' id='save-".$seq_id_d."' name='save-".$seq_id_d."' method='POST' onsubmit='return getContent".$seq_id_d."'>";
getContent defined as follows:
function getContent'.$seq_id_d.'(){
document.getElementById("seq-desc-area-'.$seq_id_d.'").value = document.getElementById("seq-desc-'.$seq_id_d.'").innerHTML;
}
Why do I get an empty return in my database when using POST? I use $_POST['deta-(the id)']to receive my message.
I also save my form using this code on a standard button. Can this do onsubmit not work ?
onclick='document.forms['save-".$seq_id_d."'].submit();'
I tried to find out what the problem was for a while, and I really need someone's opinion.
UPDATE:
Using console.log(), I do not get a return inside the function. Therefore, the function does not work.
Full code can be found here.
getContent-'.$seq_id_d.'()getContent_'.$seq_id_d.'()- textarea
document.getElementById("seq-desc-area-'.$seq_id_d.'").valuedocument.getElementById("seq-deta-area-'.$seq_id_d.'").value - onsubmit
onsubmit='return getContent-".$seq_id_d."'onsubmit='return getContent_".$seq_id_d."()'
, :)
<?php
$seq_id_d = 1;
var_dump($_REQUEST);
?>
<div id='seq-desc-<?php echo $seq_id_d; ?>' contenteditable='true' data-text='Det som skal skje...'>werwerwqrewrqwer</div>
<form id='save-<?php echo $seq_id_d; ?>' name='save-<?php echo $seq_id_d; ?>' method='POST' onsubmit='return getContent_<?php echo $seq_id_d; ?>()'>
<textarea id='seq-deta-area-<?php echo $seq_id_d; ?>' name='deta-<?php echo $seq_id_d; ?>' style='display: none;'></textarea>
<input type="submit" value="ok">
</form>
<script>
function getContent_<?php echo $seq_id_d; ?>(){
document.getElementById("seq-deta-area-<?php echo $seq_id_d; ?>").value = document.getElementById("seq-desc-<?php echo $seq_id_d; ?>").innerHTML;
}
</script>