textarea

Neatest (and fast) way to remove top lines from a textarea

北城以北 提交于 2019-12-01 22:48:59
问题 I have a webpage that displays last 1000 lines of a logfile then updates via AJAX every x seconds loading new content (if any) and appending to textarea with $('#log').append(new_data) , a sort of tail -f . The problems come up after some time when too many lines are appended and the page becomes slow or unresponsive. So I'd like to limit number of lines to, say, 5000 so it means I should: retrieve new_data calculate overflow = 5000 - lines_ in_new_data - lines_in_textarea if overflow > 0

How to set a value of the textarea without id by javascript?

假如想象 提交于 2019-12-01 22:47:22
问题 Typically we run javascript code to set any value: document.getElementById('id_name').value = "..."; But I have a page like this: <div id="id_name"> <div class="class_name"> <textarea></textarea> </div> </div> How to set a value of the textarea by javascript? Thanks a lot for help! 回答1: You could do this, if your HTML is really that simple: var textarea = document.getElementById('id_name').getElementsByTagName('textarea')[0]; textarea.value = "hello world"; There's also a

php htmlentities to decode textarea

拈花ヽ惹草 提交于 2019-12-01 22:40:34
问题 I have a text area and I would like to take the input of the text area and merge it all together. Everything works fine except that it's escaping the quotes. For example test's is outputted as test/'s To fix this I tried htmlenttries such as, <?php $inputtext= $_POST['textinput']; $encodetext = htmlentities($inputtext); $finaltext = html_entity_decode($encodetext); echo '<p>'.$finaltext .'</p>'; ?> This should work according to the html_entity_decode manual (unless I read it wrong which could

How to stop window jumping when typing in autoresizing textarea

♀尐吖头ヾ 提交于 2019-12-01 22:36:23
I am using the accepted answer to this question to build a textarea that expands vertically as text overflows: <!DOCTYPE html> <html> <head> <title>autoresizing textarea</title> <style type="text/css"> textarea { border: 0 none white; overflow: hidden; padding: 0; outline: none; background-color: #D0D0D0; resize: none; } </style> <script type="text/javascript"> var observe; if (window.attachEvent) { observe = function (element, event, handler) { element.attachEvent('on'+event, handler); }; } else { observe = function (element, event, handler) { element.addEventListener(event, handler, false);

Neatest (and fast) way to remove top lines from a textarea

空扰寡人 提交于 2019-12-01 22:28:04
I have a webpage that displays last 1000 lines of a logfile then updates via AJAX every x seconds loading new content (if any) and appending to textarea with $('#log').append(new_data) , a sort of tail -f . The problems come up after some time when too many lines are appended and the page becomes slow or unresponsive. So I'd like to limit number of lines to, say, 5000 so it means I should: retrieve new_data calculate overflow = 5000 - lines_ in_new_data - lines_in_textarea if overflow > 0 remove first overflow lines from textarea append new_data to textarea In my mind this involves one or more

populating a textarea with special characters

我的梦境 提交于 2019-12-01 22:23:57
问题 I'm populating a textarea with previous input of a user. This is pulled from a database and set as the content of the textarea server side. It seems we are having an issue with a typo and a combination of special characters. if the user inputs &#6 originally, when I try to populate my textarea with that it just renders a little square like its interpreting the character encoded value. Creating a HTML file with the following demonstrates my issue. <textarea name"mytextarea">some text &#5 some

carriage return in textarea retrieved as line feed

巧了我就是萌 提交于 2019-12-01 22:11:31
问题 How can I preserve a carriage return character in a text area? textarea.value = "X" + String.fromCharCode("13") + "X"; textarea.value.charCodeAt(1); //returns 10, not 13 See here: http://jsfiddle.net/vah9e/ 回答1: According to W3C Textarea api value, it seems that when invoking the .value attribute of textarea , any carriage return or line feed is transformed into a LINE FEED (10) character (in fact W3C says CRFL but it seems the browsers prefer only LF ) - so a script can be platform

How to stop window jumping when typing in autoresizing textarea

跟風遠走 提交于 2019-12-01 21:59:08
问题 I am using the accepted answer to this question to build a textarea that expands vertically as text overflows: <!DOCTYPE html> <html> <head> <title>autoresizing textarea</title> <style type="text/css"> textarea { border: 0 none white; overflow: hidden; padding: 0; outline: none; background-color: #D0D0D0; resize: none; } </style> <script type="text/javascript"> var observe; if (window.attachEvent) { observe = function (element, event, handler) { element.attachEvent('on'+event, handler); }; }

carriage return in textarea retrieved as line feed

主宰稳场 提交于 2019-12-01 21:09:28
How can I preserve a carriage return character in a text area? textarea.value = "X" + String.fromCharCode("13") + "X"; textarea.value.charCodeAt(1); //returns 10, not 13 See here: http://jsfiddle.net/vah9e/ Arglanir According to W3C Textarea api value , it seems that when invoking the .value attribute of textarea , any carriage return or line feed is transformed into a LINE FEED (10) character (in fact W3C says CRFL but it seems the browsers prefer only LF ) - so a script can be platform-independent on line feeds. In a form data, it seems that the fine feeds are transformed into CRLF (13+10).

How to set a value of the textarea without id by javascript?

我的未来我决定 提交于 2019-12-01 21:05:36
Typically we run javascript code to set any value: document.getElementById('id_name').value = "..."; But I have a page like this: <div id="id_name"> <div class="class_name"> <textarea></textarea> </div> </div> How to set a value of the textarea by javascript? Thanks a lot for help! You could do this, if your HTML is really that simple: var textarea = document.getElementById('id_name').getElementsByTagName('textarea')[0]; textarea.value = "hello world"; There's also a "getElementsByClassName()" in newer browsers that could be used to find the "class_name" <div> element, from which you'd do the