El caso es que tengo un editor de texto para editar un comentario de mi web que se guarda en una base de datos, y me gustaría que cuando hay un dato guardado en el registro y alguien accede al editor de texto este dato que sera un texto aparezca en lo que es el iframe donde se edita el texto para después guardarlo en el registro de la base de datos, es decir si hay ya un registro y alguien quiere volver a editarlo que lo pueda ver en el editor para posterior modificarlo y volverlo aguardar. he intentado dándole la propiedad de value al iframe poniendo dentro de value el registro de la base de datos pero no funciona.
no se quizas sea por la parte de javascript dándole valor a lo que se llama textEditor que es el id que después se le da al iframe para editar el texto, no se si me explico bien pongo el código de la pagina para ver si alguien puede darme una idea.
Código HTML:
Ver original
<html> <head> <script language="javascript"> function setHidden() { var frameContent=textEditor.document.body.innerHTML; document.getElementById('comentario1').value=frameContent; } <!-- function def() { var testframe = document.createElement("iframe"); testframe.name = testframe.id = "textEditor"; if (testframe.addEventListener){ testframe.addEventListener("load",function(e){this.contentWindow.document.designMode = "on";}, false); } else if (testframe.attachEvent){ testframe.attachEvent("load", function(e){this.contentWindow.document.designMode = "on";}); } textEditor.document.designMode="on"; textEditor.document.open(); textEditor.document.write('<head><style type="text/css">body{ font-family:arial; font-size:25px; }</style> </head>');//esta linea nos da el estilo con el que escribimos dentro del iframe demomento solo se eso textEditor.document.close(); textEditor.focus(); } function fontEdit(x,y) { textEditor.document.execCommand(x,"",y); textEditor.focus(); } --> </script> </head> <body onLoad="def()" ><center> <div style="width:500px; text-align:left; margin-bottom:10px "> <input type="button" id="bold" style="height:21px; width:21px; font-weight:bold;" value="B" onClick="fontEdit('bold')" /> <input type="button" id="italic" style="height:21px; width:21px; font-style:italic;" value="I" onClick="fontEdit('italic')" /> <input type="button" id="underline" style="height:21px; width:21px; text-decoration:underline;" value="U" onClick="fontEdit('underline')" /> <input type="button" style="height:21px; width:21px;"value="L" onClick="fontEdit('justifyleft')" title="align left" /> <input type="button" style="height:21px; width:21px;"value="C" onClick="fontEdit('justifycenter')" title="center" /> <input type="button" style="height:21px; width:21px;"value="R" onClick="fontEdit('justifyright')" title="align right" /> <select id="fonts" onChange="fontEdit('fontname',this[this.selectedIndex].value)"> </select> <select id="size" onChange="fontEdit('fontsize',this[this.selectedIndex].value)"> </select> <select id="color" onChange="fontEdit('ForeColor',this[this.selectedIndex].value)"> </select> <input type="button" style="height:21px; width:21px;"value="1" onClick="fontEdit('insertorderedlist')" title="Numbered List" /> <input type="button" style="height:21px; width:21px;"value="•" onClick="fontEdit('insertunorderedlist')" title="Bullets List" /> <input type="button" style="height:21px; width:21px;"value="«" onClick="fontEdit('outdent')" title="Outdent" /> <input type="button" style="height:21px; width:21px;"value="»" onClick="fontEdit('indent')" title="Indent" /> </div> <form action="accesocomentario1.php" method="post" onSubmit="setHidden()"> <input type="hidden" name="comentario1" id="comentario1" /> <input type="hidden" name="web" id="web" value="<?php echo $_SESSION['MM_Username']; ?>"/> <input type="submit" value="submit" /> </form> <iframe id="textEditor" style="width:450px; height:160px; background-color:#FFF;" frameborder="1" > </iframe> </center> </body> </html> <?php mysql_free_result($textostienda); ?>
gracias por este foro