textarea problems

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Blondy
Forum Commoner
Posts: 32
Joined: Thu Mar 06, 2008 5:55 pm

textarea problems

Post by Blondy »

hi guys
I want to have a text area that get more height eachtime I press enter and make the text longer I saw that on phpmyadmin.
and also when I add the text on mysql I see that it puts all text in one line why that happens and how to fix it?
I used text on sql code for it's row.

thanks sarah.
Walid
Forum Commoner
Posts: 33
Joined: Mon Mar 17, 2008 8:43 am

Re: textarea problems

Post by Walid »

This is a javascript issue. Not PHP.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: textarea problems

Post by pickle »

Moved to Client Side.

To answer your questions:
1) You could add a javascript listener to the textarea & every time [enter] is typed, grow the height of the textarea by 1 em. A textarea might have special properties such as the # of lines it's text has too - don't know though.

2) Your second question leads to more questions. What is being "added" to mysql? Where are you adding it from? How are you looking at the data & not seeing it broken on multiple lines. Note that HTML is pretty much white-space agnostic - any newline characters in the code won't appear as newlines on the page - this applies to phpMyAdmin as well.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Blondy
Forum Commoner
Posts: 32
Joined: Thu Mar 06, 2008 5:55 pm

Re: textarea problems

Post by Blondy »

~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.


thanks pickle
for more information I got something useful
the text have lines when I try to edit them on the form I added them
but on the page that I want to view them the lines are gone!
so the problem should be there when I call them from mysql
it's a function on functions.php
code is this

Code: Select all

//------Show Intro
function show_intro(){
    require("config.php");
    mysql_connect($sqlhost,$sqluser,$sqlpass);
    mysql_select_db($sqldb);
    $sqlsel = "SELECT * FROM intro";
    $result = mysql_query($sqlsel) or die(mysql_error() . "<br>Could not select news.");
    $r = mysql_fetch_array($result);
    $I_title=$r[subject];
    $I_text=$r[intro];
echo "
<h1>$I_title</h1>";
echo $I_text;<--this One is my problem-->
}
 

~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: textarea problems

Post by pickle »

Like I said, newline characters are not interpreted in HTML. If $I_text contains newlines, they will not have any effect in a web page. If you want newline characters to do something, you'll need to wrap $I_text in <pre></pre> tags.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply