textarea

How to select line of text in textarea

吃可爱长大的小学妹 提交于 2019-11-27 20:50:55
I have a textarea that is used to hold massive SQL scripts for parsing. When the user clicks the "Parse" button, they get summary information on the SQL script. I'd like the summary information to be clickable so that when it's clicked, the line of the SQL script is highlighted in the textarea. I already have the line number in the output so all I need is the javascript or jquery that tells it which line of the textarea to highlight. Is there some type of " goToLine " function? In all my searching, nothing quite addresses what I'm looking for. This function expects first parameter to be

Max characters in textarea with jquery

我怕爱的太早我们不能终老 提交于 2019-11-27 20:30:46
I have the following code, and I'm kind of stuck on what to do next. The idea is when you enter text into a text area a counter tells you how many characters you have left. Once you get to the max characters I want to stop allowing characters to be entered, or delete all the characters that were entered so there are only 10 characters in the text area. I know I have to put the code where it says alert("LONG"); but I'm not quite sure what. var maxLen = 10; console.log("Start"); $('#send-txt').keyup(function(){ var Length = $("#send-txt").val().length; var AmountLeft = maxLen - Length; $('#txt

Preserve line breaks in textarea

耗尽温柔 提交于 2019-11-27 20:22:05
I have a form with a textarea and I want to preserve line breaks entered by the user when outputting the content. For exemple, if I write in textarea : Here is a sentence. Here is another. here is one more. This is a new paragraph. Here is a new sentence. Here is another. I want the same output and not : Here is a sentence. Here is another. here is one more. This is a new paragraph. Here is a new sentence. Here is another. How could I preserve line breaks? Vaidotas Pocius Generally you just need to add white-space: pre-line; whitespace trimmed to single whitespace or white-space: pre-wrap; all

How to get the height of the text inside of a textarea

久未见 提交于 2019-11-27 20:03:56
I have a textarea with the the text Hello World . I would like to get the height of this text. I've tried to use: var element = document.getElementById('textarea'); var textHeight = element.innerHTML.offsetHeight; and: var textHeight = element.value.offsetHeight; But these don't give the numbers of the text, but the height of the textarea element. Create a span element, set Span's innerHTML to "Hello World". Get the span's offsetHeight. var span = document.createElement("span"); span.innerHTML="Hello World"; //or whatever string you want. span.offsetHeight // this is the answer note that you

Autocomplete functionality on a textarea [closed]

て烟熏妆下的殇ゞ 提交于 2019-11-27 19:21:18
Is there a way to implement auto-complete functionality in a region defined by textarea tags or something similar? I'm currently using a jQuery auto-complete plugin to suggest input to the user inside input tags, but the issue is that the auto-complete phrases can often be fairly long and thus scroll off the edge of the input field. You can use the jQueryUI autocomplete widget on textareas. A working example: http://output.jsbin.com/cezemetida/1 HTML: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Textarea Autocomplete</title> <meta http-equiv

Height of textarea does not match the rows in Firefox

为君一笑 提交于 2019-11-27 18:58:21
The textarea's rows attribute does not match the number of lines in Firefox. For instance: <textarea rows=4 cols=40> 1 2 3 4 this line is visible in FF </textarea> Example: http://jsfiddle.net/Z7zXs/6/ How can I fix this issue? The textarea should only display 4 lines (instead of 5) for rows=4 . Lekensteyn Firefox always adds an extra line after the textfield. If you want it to have a constant height, use CSS, e.g.: textarea { height: 5em; } http://jsfiddle.net/Z7zXs/7/ EDIT: You can also use the @-moz-document url-prefix CSS extension to target only the Firefox browser. Example @-moz-document

Print when textarea has overflow

笑着哭i 提交于 2019-11-27 18:43:50
I have a form with some text areas that allow a scroll bar when the text exceeds the text box. The user would like to be able to print the screen, and this text is not visible. How do I make all of the text visible for just printing? Am I better of making a print to pdf link or something? You cannot solve this problem with CSS alone. Why Pure-CSS Solutions are Insufficient (with demo) Let me convince you the answers involving print stylesheets and overflow: visible are insufficient. Open this page and look at the source. Just what they suggested, right? Now print preview it (in, say, Chrome 13

Highlight text as you type on textarea

試著忘記壹切 提交于 2019-11-27 18:24:32
I'm trying to create a textarea that will highlight some keywords as the user types in there. I understant textarea can only support plain text and that I have to use a 'rich text' editor in order to achieve this. I would like something really simple though and not the bloated 'rich editors' out there. Any ideas? Thanks! Todd H. Here is a snippet that gives you the basics of what are looking for: <style> .textarea { font-family:arial; font-size:12px; border:0; width:700px; height:200px; } .realTextarea { margin:0; background:transparent; position: absolute; z-index:999; } .overlayTextarea {

Get each line from textarea

老子叫甜甜 提交于 2019-11-27 17:30:39
<textarea> put returns between paragraphs for linebreak add 2 spaces at end indent code by 4 spaces quote by placing > at start of line </textarea> $text = value from this textarea; How to: 1) Get each line from this textarea ( $text ) and work with them using foreach() ? 2) Add <br /> to the end of each line, except the last one? 3) Throw each line to an array. Important - text inside textarea can be multilanguage. Have tried to use: $text = str_replace('\n', '<br />', $text); But it doesn't work. Thanks. Brad F Jacobs You will want to look into the nl2br() function along with the trim() .

Max lines textarea

≡放荡痞女 提交于 2019-11-27 16:56:51
问题 I have found some scripts that limit the lines used in a textarea like this: $(document).ready(function(){ var lines = 10; var linesUsed = $('#linesUsed'); var newLines=0; $('#rev').keydown(function(e) { newLines = $(this).val().split("\n").length; linesUsed.text(newLines); if(e.keyCode == 13 && newLines >= lines) { linesUsed.css('color', 'red'); return false; } else { linesUsed.css('color', ''); } }); It works fine when you hit enter and limits it to 10 .But the problem occurs when you type