Find out the ‘line’ (row) number of the cursor in a textarea

You would want to use selectionStart to do this. <textarea onkeyup=”getLineNumber(this, document.getElementById(‘lineNo’));” onmouseup=”this.onkeyup();”></textarea> <div id=”lineNo”></div> <script> function getLineNumber(textarea, indicator) { indicator.innerHTML = textarea.value.substr(0, textarea.selectionStart).split(“\n”).length; } </script> This works when you change the cursor position using the mouse as well.

Autocomplete functionality on a textarea [closed]

You could also (two years later, mind you) try asuggest, it offers word completion inside the textarea after the caret. A simple example: var suggests = [“hello”, “world”]; $(“#text-area1”).asuggest(suggests); This will match things easily, no limits, no minimum character count. More bells and whistles: var suggests = [“head”, “hello”, “heart”, “health”]; $(“#text-area1”).asuggest(suggests, { ‘endingSymbols’: ‘, … Read more

ReactJS component not rendering textarea with state variable

Check this link from react docs: React Textarea Value Basically for textArea react does not supports text enclosed within and you rather need to specify that as value or defaultValue. The right way thus is <textarea name=”description” value=”This is a description.” /> or <textarea name=”description” defaultValue=”This is a description.” /> The difference with value and … Read more

textarea character limit

I found a good solution that uses the maxlength attribute if the browser supports it, and falls back to an unobtrusive javascript pollyfill in unsupporting browsers. Thanks to @Dan Tello’s comment I fixed it up so it works in IE7+ as well: HTML: <textarea maxlength=”50″ id=”text”>This textarea has a character limit of 50.</textarea> Javascript: function … Read more

Rails 3: How to display properly text from “textarea”?

Rails got a helper method out of the box, so you dont have to write your own method. From the documentation: simple_format(text, html_options={}, options={}) my_text = “Here is some basic text…\n…with a line break.” simple_format(my_text) # => “<p>Here is some basic text…\n<br />…with a line break.</p>” more_text = “We want to put a paragraph…\n\n…right there.” … Read more

How to make textarea to fill div block?

Please refer to this article which implements the CSS3 box-sizing property http://css-tricks.com/box-sizing/ A quick solution for this is to set textarea { width: 100%; -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */ -moz-box-sizing: border-box; /* Firefox, other Gecko */ box-sizing: border-box; /* Opera/IE 8+ */ } And here is a working example which implements the box-sizing … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)