i have a table in a mysql database that has multi lines.
i use javascript to populate textarea controls but the multiline causes a break in the java code which causes errors.
how do i get a multiline field into a textarea??
maybe post some code to help us? and please, only relevant code - not the entire internet - as beer makes the eyes tired.
at first guess, maybe use ereg functions to replace "<BR>" with "/n" in the code?
<textarea name="notes" class="textbox" cols="50" rows="5"></textarea> <? ... print "<script>"; print "document.form1.notes.value = '$row[Notes]';"; print "</script>"; ... ?> [result html src code] <textarea name="notes" class="textbox" cols="50" rows="5"></textarea> <script> document.form1.notes.value = 'line1 line2 line3' </script> ----------------------------------------- this causes javascript errors
ok change the js line to match this
print "document.form1.notes.value = '" . nl2br($row[Notes]) . "';";
the function nl2br takes a string and changes all the newline \n to html <BR>'s the code now won't break the js
adam
thnx
<script> document.form1.notes.value = 'line1 <br>line2 <br>line3' </script>
still gives javascript error
Originally posted by Gasolene <textarea name="notes" class="textbox" cols="50" rows="5"></textarea> <? ... print "<script>"; print "document.form1.notes.value = '$row[Notes]';"; print "</script>"; ... ?> [result html src code] <textarea name="notes" class="textbox" cols="50" rows="5"></textarea> <script> document.form1.notes.value = 'line1 line2 line3' </script> ----------------------------------------- this causes javascript errors [/B][/QUOTE] do it this way <textarea name="notes" class="textbox" cols="50" rows="5"><?php echo $row['notes']; ?></textarea> avoid using javascript completely I thougth you had multiline input from database? if you are and you are gonna do: echo $row['notes1'].$row['notes2'].$row['notes3']; add newlines (textblocks use \n for line breaks not <br>) eg) echo $row['notes1']."\n".$row['notes2']."\n".$row['notes3'];
Originally posted by Gasolene
<textarea name="notes" class="textbox" cols="50" rows="5"></textarea> <? ... print "<script>"; print "document.form1.notes.value = '$row[Notes]';"; print "</script>"; ... ?> [result html src code] <textarea name="notes" class="textbox" cols="50" rows="5"></textarea> <script> document.form1.notes.value = 'line1 line2 line3' </script> ----------------------------------------- this causes javascript errors [/B][/QUOTE] do it this way <textarea name="notes" class="textbox" cols="50" rows="5"><?php echo $row['notes']; ?></textarea> avoid using javascript completely I thougth you had multiline input from database? if you are and you are gonna do: echo $row['notes1'].$row['notes2'].$row['notes3']; add newlines (textblocks use \n for line breaks not <br>) eg) echo $row['notes1']."\n".$row['notes2']."\n".$row['notes3'];