Click to See Complete Forum and Search --> : Jscript in Html page called from PHP


ciano
12-22-2006, 05:06 AM
I am not a Web programmer but I was dropped this problem to help a friend..you know the usual "you know about computers thing!"

Well in short the site is using PHP and an HTML form to enter documents in a database. The problem is that a Textarea is used to enter the data so the text posted is displayed without any formatting...not nice.

I found a jscript on the web (tinyMCE) that allows to enter formatting in any textarea, pretty neat and painless. My problem is that if I open the html page it works (locally or on the web site) but when the page is loaded from the PHP script it doesn't work.

To avoid posting all the scripts I think the PHP code that call the html page is:
$option_day= do_select_voice($array_day);
$option_months= do_select_voice($months);
$option_cat= do_select_voice($array_cat);

eval ("\$content = \"".template("form.html")."\";");
eval("print(\"".template("template.html")."\");");
The textarea in in form.html and the jscript is called like this:
<tr>
<!-- tinyMCE -->
<script language="javascript" type="text/javascript" src="../jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
// Notice: The simple theme does not use all options some of them are limited to the advanced theme
tinyMCE.init({
mode : "textareas",
theme : "simple"
});
</script>
<!-- /tinyMCE -->

<td align="right"><strong>Testo * </strong></td>
<td><textarea name="testo" cols="50" rows="10" id="textarea">$testo</textarea></td>
</tr>

I have the feeling that by loading the page from PHP the jscript is not loaded because the page is loaded normally but without the editor (similar to the one I am posting right now).
I have tried to look around for some hints or solution but I soon realized that I am well over my head. Any help is appreciated.

Cheers,
Luciano

ellanab
12-23-2006, 04:14 AM
TinyMCE ony adds this script to text areas.
If you are using headers and footers. Add the script in the <head> portion of the header file.

ciano
12-23-2006, 08:50 AM
That was the first implementation but it didn't work, then I read somewhere that jscript inside php is not executed until the page is completely loaded so I placed it at the end of the page. I tried to place it before </body> and then just before </html> but the jscript is not running. When I look at the source of the loaded page the script is there. Any other ideas?