Jump to content

Need Help with textfield


Danny620

Recommended Posts

Sounds like you want something like this - http://ckeditor.com/download

I currently use it on my site

 

Then you call it like so

<script type="text/javascript" src="../ckeditor/ckeditor.js"></script>
<script language="javascript" type="text/javascript">
window.onload = function()
{
	CKEDITOR.replace( 'newscontent' );
};
</script>

 

Then make sure you have say newscontent is assigned to a textfield - eg

<textarea name="newscontent" id="newscontent" rows="15">'.$newscontent.'</textarea>

 

Ignore my '.$newscontent.' as i use that variable to save and insert new content etc

Well to be honest i think it will be simpler to just use a HTML editor

 

Or try this

$value = str_replace(array( "\r", "\n", "%0a", "%0d"), ' ', $value);

 

http://php.net/manual/en/function.nl2br.php

 

 

Or something like this

$your_string = str_replace(array(chr(10), chr(13)), "<br />", $your_string);

So to basically replace newline with linebreak you use

$your_string = str_replace(array(chr(10), chr(13)), "<br />", $your_string);

on the value thats going into the database

 

But then when you come to view the data in the text area or whatever it will have linebreaks on it, so to convert back from linebreaks to newline we use this function

function br2nl($string)
{
    return preg_replace('/\<br(\s*)?\/?\>/i', "\n", $string);
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.