Welcome Guest, Not a member yet? Register   Sign In
[Solved] Textarea indent 4 spaces jQuery & Codeigniter
#3

(This post was last modified: 12-21-2016, 12:36 AM by wolfgang1983.)

(12-21-2016, 12:20 AM)salain Wrote: Hi,

I have not tested it, but is should work.
What you need to do is to find the newline and add your startTag to each line.
Because of different character for new line on Windows, Linux and Mac you need to test for all 3.
You will notice I use the \r\n (Windows linebreak) to insure it works on most systems


PHP Code:
function wrapText(elementIDopenTagcloseTag) {
 
   var textArea = $('#' elementID);
 
   var len textArea.val().length;
 
   var start textArea[0].selectionStart;
 
   var end textArea[0].selectionEnd;
 
   var selectedText textArea.val().substring(startend);
 
   var replacement openTag selectedText closeTag;

 
   replacement.replace(/\r\n|\r|\n/g,"\r\n"+openTag);

 
   textArea.val(textArea.val().substring(0start) + replacement textArea.val().substring(endlen));


Source 1 for the solution
Source 2

It's only when I click on my button for it I though And I am not after line break
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Messages In This Thread
RE: Textarea indent 4 spaces jQuery & Codeigniter - by wolfgang1983 - 12-21-2016, 12:33 AM



Theme © iAndrew 2016 - Forum software by © MyBB