Mon code est composé d une partie en javascript m affichant le tableau et l autre l'appel de du javascript autrement dit un main()...
Code de mon javascipt
function writeRichText(rte, html, width, height, buttons, readOnly) {
if (allRTEs.length > 0) allRTEs += ";";
allRTEs += rte;
writeRTE(rte, html, width, height, buttons, readOnly);
}
function writeDefault(rte, html, width, height, buttons, readOnly) {
if (!readOnly) {
document.writeln('<textarea name="' + rte + '" id="' + rte + '" style="width: ' + width + 'px; height: ' + height + 'px;">' + html + '</textarea>');
} else {
document.writeln('<textarea name="' + rte + '" id="' + rte + '" style="width: ' + width + 'px; height: ' + height + 'px;" readonly>' + html + '</textarea>');
}
}
function writeRTE(rte, html, width, height, buttons, readOnly) {
//adjust minimum table widths
if (isIE) {
if (buttons && (width < 600)) width = 600;
var tablewidth = width;
} else {
if (buttons && (width < 500)) width = 500;
var tablewidth = width + 4;
}
if (buttons == true) {
document.writeln('<h3> Formulaire Carnet de voyage</h3>');
document.writeln('<form name="form" id="essai" enctype="multipart/form-data" method="post">');
document.writeln('<table class="rteBack" cellpadding=2 cellspacing=0 id="Buttons1_' + rte + '" width="' + tablewidth + '">');
document.writeln('<tr>');
document.writeln(' <td>Pseudo :</td>');
document.writeln(' <td COLSPAN=2><input readonly size=35 name=pseudo_carnet_voyage value=<? echo $val_pseudo; ?>');
document.writeln('</td>');
document.writeln('<tr>');
document.writeln(' <td>Titre carnet de voyage :</td>');
document.writeln(' <td COLSPAN=2><input size=35 name=titre_carnet_voyage></td>');
document.writeln('</td>');
document.writeln('</tr>');
document.writeln('<tr>');
document.writeln(' <td>Date de voyage :</td>');
document.writeln(' <td COLSPAN=2>');
document.writeln(' <select name="jour_voyage">');
document.writeln(' <option value="" selected>Jour </option>');
for (i=1; i<32; i++) {
document.writeln(' <option value=' + i + '>' + i + '</option>');
}
document.writeln(' </select>');
document.writeln(' <select name="mois_voyage" >');
document.writeln(' <option value="" selected>Mois </option>');
document.writeln(' <option value="01">Janvier</option>');
document.writeln(' <option value="02">Fevrier</option>');
document.writeln(' <option value="03">Mars</option>');
document.writeln(' <option value="04">Avril</option>');
document.writeln(' <option value="05">Mai</option>');
document.writeln(' <option value="06">Juin</option>');
document.writeln(' <option value="07">Juillet</option>');
document.writeln(' <option value="08">Aout</option>');
document.writeln(' <option value="09">Septenbre</option>');
document.writeln(' <option value="10">Octobre</option>');
document.writeln(' <option value="11">Novembre</option>');
document.writeln(' <option value="12">Decembre</option>');
document.writeln(' </select>');
document.writeln(' <select name="annee_voyage">');
document.writeln(' <option value="" selected>Année </option>');
for (i=1920; i<2007; i++) {
document.writeln(' <option value=' + i + '>' + i + '</option>');
}
document.writeln(' </select>');
document.writeln(' </td>');
document.writeln(' </tr>');
document.writeln('<tr>');
document.writeln(' <td>Date de Publication :</td>');
document.writeln(' <td COLSPAN=2><input readonly size=35 name=date_publication_carnet_voyage value=<? echo $date; ?>></td>');
document.writeln('</tr>');
document.writeln('<tr>');
document.writeln(' <td>Photos de voyages(Max 5) :</td>');
document.writeln(' <td> A faire + tard qd j aurais fini la gestion des images !!!</td>');
document.writeln('</tr>');
document.writeln('<tr>');
document.writeln(' <td>Commentaires :</td>');
document.writeln(' <td class=tdtitre>');
document.writeln(' <select id="fontname_' + rte + '" onchange="Select(\'' + rte + '\', this.id)">');
document.writeln(' <option value="Police" selected>Police</option>');
document.writeln(' <option value="Arial, Helvetica, sans-serif">Arial</option>');
document.writeln(' <option value="Courier New, Courier, mono">Courier New</option>');
document.writeln(' <option value="Times New Roman, Times, serif">Times New Roman</option>');
document.writeln(' <option value="Verdana, Arial, Helvetica, sans-serif">Verdana</option>');
document.writeln(' <option value="comic sans ms">Comic</option>');
document.writeln(' <option value="Tahoma">Tahoma</option>');
document.writeln(' </select>');
document.writeln(' <select unselectable="on" id="fontsize_' + rte + '" onchange="Select(\'' + rte + '\', this.id);">');
for (i=1; i<30; i++) {
document.writeln(' <option value=' + i + '>' + i + '</option>');
}
document.writeln(' </select>');
document.writeln(' <tr>');
document.writeln(' </td>');
document.writeln(' </td>');
document.writeln(' </tr>');
document.writeln('</table>');
document.writeln('<table id="Buttons2_' + rte + '" cellpadding="1" cellspacing="0">');
document.writeln(' <tr>');
document.writeln(' <td class=tdcontenu><img class="rteImage" src="' + imagesPath + 'bold.gif" width="25" height="24" alt="Bold" title="Gras" onClick="FormatText(\'' + rte + '\', \'bold\', \'\')"></td>');
document.writeln(' <td class=tdcontenu><img class="rteImage" src="' + imagesPath + 'italic.gif" width="25" height="24" alt="Italic" title="Italique" onClick="FormatText(\'' + rte + '\', \'italic\', \'\')"></td>');
document.writeln(' <td class=tdcontenu><img class="rteImage" src="' + imagesPath + 'underline.gif" width="25" height="24" alt="Underline" title="Soulignage" onClick="FormatText(\'' + rte + '\', \'underline\', \'\')"></td>');
document.writeln(' <td class=tdcontenu><img class="rteImage" src="' + imagesPath + 'left_just.gif" width="25" height="24" alt="Align Left" title="Aligné à gauche" onClick="FormatText(\'' + rte + '\', \'justifyleft\', \'\')"></td>');
document.writeln(' <td class=tdcontenu><img class="rteImage" src="' + imagesPath + 'centre.gif" width="25" height="24" alt="Center" title="Centré" onClick="FormatText(\'' + rte + '\', \'justifycenter\', \'\')"></td>');
document.writeln(' <td class=tdcontenu><img class="rteImage" src="' + imagesPath + 'right_just.gif" width="25" height="24" alt="Aligné à droite" title="Aligné à droite" onClick="FormatText(\'' + rte + '\', \'justifyright\', \'\')"></td>');
document.writeln(' <td class=tdcontenu><img class="rteImage" src="' + imagesPath + 'justifyfull.gif" width="25" height="24" alt="Justify Full" title="Justifié" onclick="FormatText(\'' + rte + '\', \'justifyfull\', \'\')"></td>');
document.writeln(' <td class=tdcontenu><img class="rteImage" src="' + imagesPath + 'hr.gif" width="25" height="24" alt="Horizontal Rule" title="Barre Horizontal" onClick="FormatText(\'' + rte + '\', \'inserthorizontalrule\', \'\')"></td>');
document.writeln(' <td class=tdcontenu><img class="rteImage" src="' + imagesPath + 'numbered_list.gif" width="25" height="24" alt="Ordered List" title="Liste ordonnée" onClick="FormatText(\'' + rte + '\', \'insertorderedlist\', \'\')"></td>');
document.writeln(' <td class=tdcontenu><img class="rteImage" src="' + imagesPath + 'list.gif" width="25" height="24" alt="Unordered List" title="Utilisation de puces" onClick="FormatText(\'' + rte + '\', \'insertunorderedlist\', \'\')"></td>');
document.writeln(' <td class=tdcontenu><img class="rteImage" src="' + imagesPath + 'outdent.gif" width="25" height="24" alt="Outdent" title="Réduire le retrait" onClick="FormatText(\'' + rte + '\', \'outdent\', \'\')"></td>');
document.writeln(' <td class=tdcontenu><img class="rteImage" src="' + imagesPath + 'indent.gif" width="25" height="24" alt="Indent" title="Augmenter le retrait" onClick="FormatText(\'' + rte + '\', \'indent\', \'\')"></td>');
document.writeln(' <td class=tdcontenu><div id="forecolor_' + rte + '"><img class="rteImage" src="' + imagesPath + 'textcolor.gif" alt="Text Color" title="Couleur de texte" onClick="FormatText(\'' + rte + '\', \'forecolor\', \'\')"></div></td>');
document.writeln(' <td COLSPAN=3 ROWSPAN=1 class=tdcontenu><div id="hilitecolor_' + rte + '"><img class="rteImage" src="' + imagesPath + 'bgcolor.gif" alt="Background Color" title="Couleur de fond" onClick="FormatText(\'' + rte + '\', \'hilitecolor\', \'\')"></div></td>');
//document.writeln(' <td class=tdcontenu><img class="rteVertSep" src="' + imagesPath + 'blackdot.gif" width="1" height="20" border="0" alt=""></td>');
document.writeln(' <td width="100%"></td>');
document.writeln(' </tr>');
document.writeln('</table>');
//}
document.writeln('<iframe id="' + rte + '" name="' + rte + '" width="' + width + 'px" height="' + height + 'px"></iframe>');
document.writeln('<iframe width="154" height="104" id="cp' + rte + '" src="' + includesPath + 'news/palette.htm" marginwidth="0" marginheight="0" scrolling="no" style="visibility:hidden; display: none; position: absolute;"></iframe>');
document.writeln('<input type="hidden" id="hdn' + rte + '" name="' + rte + '" value="">');
document.writeln('<textarea id="sc" class="textarea" name="sc" style="visibility:hidden" value=""></textarea><input type="hidden" name="posted" value="1"> <br><br><input type="submit" value="Valider"><input type="reset" value="Annuler" align="right"> <input type="hidden" value="1" name="test"></td>');
document.getElementById('hdn' + rte).value = html;
document.writeln ('<br>');
document.writeln ('<br>');
document.writeln (' <a href=/vietnampartner/maquette/index_vietnam.php>Mon compte</a><br>');
}
enableDesignMode(rte, html, readOnly);
}
Code appeleant mon javascipt :
<html>
<head>
<title>Editeur de texte</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script language="JavaScript" type="text/javascript" src="richtext.php"></script>
</head>
<body>
<script language="JavaScript" type="text/javascript">
<!--
<?
$content = RTESafe("Tappez votre texte ici" );
function RTESafe($strText) {
//returns safe code for preloading in the RTE
$tmpString = trim($strText);
return $tmpString;
}
?>
initRTE("images/", "", "" );
//-->
</script>
<noscript><p><b>Vous devez accepter le javascript pour afficher correctement l'editeur</b></p></noscript>
<script language="JavaScript" type="text/javascript">
//Usage: writeRichText(fieldname, html, width, height, buttons)
writeRichText('rte1', '<?=$content?>', 520, 200, true, false);
</script>
</body>
</html>
Ce code est pour utiliser un "rich text editor" , j ai touver du code sur le net et essayer de le comprende (mais c'est pas evident non plus j en ai compris 60% le reste ppff....)
Le but final est de tester dans mon textarea l existance ou pas d une saisie...
Mais pour cela il faut que j affecte un nom à mon "textearea" chose que je n arrive pas a arriver.. ni a quel endroit das mon main ou ds mon javascript...
donc voila
Merci