To disable a textarea with tinyMCE I used the
tinyMCE.get('id_textarea').getBody().setAttribute('contenteditable', false);
Inside a Javascript script, with an onclick event of a button, and everything went well.
The problem now is this: I have 5 pages, each page with 5 textareas, all editable by tinyMCE, and with a "Save" button for each textarea. On the last page, I inserted a "Submit" submit button, which writes a "yes" to BD mysql, a table with the textarea and the "sent" field that receives this "yes". What I'm trying to do and can not do is, after clicking on this submit button "Send", that all textarea are disabled for editing, through an SQL query to the field "sent", ie after the "yes" the user can not edit textarea anymore, nor at that time, nor after reopening pages with textarea.
I have already inserted the script in the <head>
tag, I already tried to put the script in an echo within php, and nothing was good enough to disable it, it only writes the sim in the DB. Here is the script and php / html code. Inside the <head>
tag:
function enviartudo() {
tinyMCE.get('id_textarea1').getBody().setAttribute('contenteditable', false);
tinyMCE.get('id_textarea2').getBody().setAttribute('contenteditable', false);
}
PHP
After a SELECT to DB:
include_once('conexao.php');
$query = "SELECT..........";
$data = mysqli_query($dbc, $query);
$row = mysqli_fetch_array($data);
if ($row['enviado'] == 'sim') {
echo '<script type="text/javascript">
enviartudo();
</script>';
}
if (isset($_POST['enviar'])) {
$query1 = "UPDATE tabela SET enviado = 'sim' ";
$data1 = mysqli_query($dbc, $query1);
mysqli_close($dbc);
}
HTML
<tr>
<td>
<label>TEXTAREA 1</label>
<textarea type="text" id="textarea1" name="textarea1" class="areatexto"
maxlength="5000">
<?php echo (isset($_POST['textarea1']) ? $_POST['textarea1'] :
htmlspecialchars_decode(stripslashes($row['textarea1']))); ?>
</textarea>
<input type="submit" name="submit1-1" value="Salvar" class="btn_save_item"/>
</td>
</tr>
<tr>
<td><br />
<label>TEXTAREA 2</label>
<textarea type="text" id="textarea2" name="textarea2" class="areatexto" maxlength="8000">
<?php echo (isset($_POST['textarea2']) ? $_POST['textarea2'] :
htmlspecialchars_decode(stripslashes($row['textarea2']))); ?>
</textarea>
<input type="submit" name="submit1-2" value="Salvar" class="btn_save_item" />
</td>
</tr>
<tr>
<td>
<input type="submit" name="enviar" value="Enviar" class="btn_save_item" />
</td>
</tr>
I did not put all the 5 page code with the 5 textarea of each one, because it would be very large, but the code is repetitive, changing just id / name of div, form, textarea, submit buttons, p>