FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Textbox - line break problem





flatliner
Hi there
Well I not completely sure is this the right forum for this, it ranges over a few topics, Anywho.

Basically I need to find a way via php or javascript when a user makes a line break in a textarea field?
Thats my inital problem, the reason I need to know this is for the bigger problem.

I am trying to center align text which is been maded into an image by GD lib. I made a small algothrim which did this, but the problem is if there are mulitply lines of text they don't become centered. Though I have worked out a way to do this only thing I need to know is when a user line breaks to a new line.

Thanks for taking the time to read my post, hope you can help.

Kind Regards
Ciaran
flatliner
Actually no I think I have figured it out, now to try solve my main problem with it. Here is what I used to find the line breaks in the textarea, which I really didnt think would work, but what do ya know ha. Oh and sorry its a javascript solution, proably best if this gets removed to the html and javascript forum.

Code:

<form name="fontform">
<textarea name="inputtext" id="inputtext"></textarea>
<button tilte="mo" onclick="mo();">
</form>

<script type="text/javascript">

   

function mo(){
   
var newtext = document.fontform.inputtext.value;
var x = newtext.replace(/\n/g,"{line-break}");

document.write("<p>" + x + "</p>");

};

</script>
rockacola
I think what you looking for is a simple WYSIWYG javascript class?
That way your browser can set the lines and spacings, and you can disable other styling format like bold, italic if you do not want them to use it.
flatliner
rockacola wrote:
I think what you looking for is a simple WYSIWYG javascript class?
That way your browser can set the lines and spacings, and you can disable other styling format like bold, italic if you do not want them to use it.


Maybe, but the script above does the job grand. So its all good Very Happy Very Happy Very Happy
Thanks for your reply anyway
Related topics
Basic HTML Introduction
Header("Location: PROBLEM");
So is everyone here using HTML coding???
Working with Excel, PHP & MySQL. Any Ideas
Have you ever dumped someone and realized it was a mistake?
Check out my Martial Arts Web site!
Signature Positioning Service! - CURRENTLY FREE
*Secretary for hire *
Rampant Insanity - Crits Wanted!
Line break, word wrap, HELP!!!
SQL Line breaking?
Crazy Code gone Mad!
PHP load array from $_POST
text editor w/ line numbers in JQuery, no load/change events
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.