funziona perchè tu generi codice html...
se generi codice javascript non funziona
Codice PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="it" xml:lang="it">
<head>
<title>:: Prova nl2br</title>
</head>
<body>
<?php
if(isset($_POST['invia']))
{
$testo_formattato = str_replace("
", "", $_POST['testo']);
$testo_formattato = nl2br($testo_formattato);
}
?>
<form name="formname" method="post">
<textarea name="testo" rows="10" cols="50"></textarea>
<input type="submit" name="invia" />
</form>
</body>
</html>
<?
echo '<script language=javascript>document.formname.testo.value="'.$testo_formattato.'";</script>';
?>
io ho la necessità di usare javascript..