Menu
  • HOME
  • TAGS

Safely store textarea input with newlines and preserve linebreaks

php,mysqli,textarea,nl2br

You could translate them into their respective escape sequences using str_replace before passing the string through nl2br(). This is an example: $profile = nl2br(str_replace('\\r\\n', "\r\n", $profile['presentation'])); ...

Create textarea with same style as angular validation

javascript,angularjs,textarea

I realized what i was doing wrong, as I am new to html and css I didn't realize the class that I was calling. I simply needed to add class="form-control" to my <input>. This doesn't fix dynamically creating a red border when the input is invalid unfortunately.

How does one target a placeholder value in a textarea tag using pure javascript

javascript,append,textarea,placeholder

Although I don't quite understand what you want, here's what I think you want: var textarea = document.getElementById('test'); setInterval(function () { textarea.placeholder += ' and on'; }, 1500); <div id="comp"><textarea id='test' placeholder="Write on me now, or else... you will have to watch me write on"></textarea></div> Every 1.5 seconds, and on...

How to get mouse position in characters inside textarea with Javascript

javascript,jquery,html,textarea,dom-events

In your case it would be easier to use native ondragstart event instead of a complex mousedown-move-up implementation, and manipulate the data to drop. Something like this: document.getElementById('img').addEventListener('dragstart', function (e) { e.dataTransfer.setData("text", '[img]' + this.id + '[/img]'); }); A live demo at jsFiddle. Or a delegated version. Notice that you...

How to access clipboard and current cursor position when pasting in a textarea in IE8/9 before it becomes the current value?

javascript,internet-explorer-8,internet-explorer-9,textarea,maxlength

You can access the clipboard content with window.clipboardData.getData('Text') And manipulate it as necessary before placing it in the textbox. Be sure to return false or the paste event will fire and replace what you did. To access the current value, read the innerText value of the textarea. To get the...

Provide feedback message in textarea based on mysql data

php,mysql,textarea

I suggest building the markup in a PHP variable, and then echoing the markup all at once: <?php $average = '50'; $myquery = "SELECT `milk_solids`, `tag_number` FROM `milk` "; $row = mysqli_fetch_array($myquery); $MilkSolids = $row['milk_solids']; $TagNumber= $row['tag_number']; if ($row['milk_solids'] > 50) { $msg = 'good feedback message'; }elseif ($Milksolids <...

Textarea name given back undefined

php,html,textarea

I've remove sendmessage() and replace button type to submit. Keeping it simple. <?php if(isset($_POST['send'])){ echo "<pre>"; print_r($_POST); $message = $_POST['message']; } ?> <form action="" method="POST"> <textarea name="message" id="msgtype" placeholder="Type your message"></textarea> <input name="send" id="send" type="submit"/> </form> Try it. Hope it'll work....

Extjs5 Textarea Resizing

resize,textarea,extjs5

You width is properly resized because of the default configuration of 'anchor:100%'. On the other hand, the height it's a little bit more difficult, the idea that comes to me now is try to with a particular css (using property cls) manipulate the height (height:'100%') or something like that. Because...

CKEditor will not show echo function

php,post,ckeditor,textarea,show

valid html for text area is: <br><textarea name="body" ><?php echo $body;?></textarea> usually with rows="4" cols="50" but the ckeditor will have its own settings for this, but for fall back you may want them...

javascript / jquery: Get the changed content of textarea

javascript,jquery,html,forms,textarea

You need to use val method <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script> <form onsubmit="Output()"> <textarea id='area1'>preset</textarea> <input type="submit" value="showme"> </form> <script> function Output() { var s = $('#area1').val(); alert(s); } </script> ...

Extract the whole word from a textarea depending on where the caret is

javascript,html,html5,textarea,caret

Here is some code that will do the job. Basically, extract the caret position. Convert sentence to array. Loop array adding words lengths together, when length is greater than caret position you have found your word. <html> <script> function getCaret(node) { if (node.selectionStart) { return node.selectionStart; } else if (!document.selection)...

Check if richtextbox text area is full

c#,winforms,textarea,richtextbox

I found an answer. You can use: Size textSize = TextRenderer.MeasureText(richTextBox1.Text, richTextBox1.Font); for the size of the text then check OnContentResized event whether the MeasureText() is bigger then the height of the rich textbox....

Receiving content of textArea from another class in java (With Code) [closed]

java,class,textarea

What I need is that I want to print the result of Squre root of a number in the textArea of MainGUI class Problem #1... The JTextArea is not accessiable from outside the initialize method... private void initialize() { //... JTextArea myTextArea = new JTextArea(); You need to make...

Preserve newline in text area with Ruby on Rails

ruby-on-rails,ruby,textarea

Newlines are actually being preserved(as \r\n), you just don't see them in your index/show views. In these views, call simple_format on your post.body field to replace \ns with <br>s(HTML newlines): simple_format(post.body) From docs: simple_format(text, html_options = {}, options = {}) public Returns text transformed into HTML using simple formatting rules....

Textarea input length check in JavaScript

javascript,forms,validation,textarea

As mentioned in my comment, it depends on what you want to do with n ultimately. If you just want it to show the user a message, you can update the DOM once you've calculated this value. Your current example doesn't allow the user to delete text after they've typed/pasted...

Replace n-th tab character with a string using Javascript/jQuery

javascript,textarea

This works for your example: document.querySelector('textarea').addEventListener('paste', function() { var self= this; setTimeout(function() { self.value = self.value.split(/\t+/) .map(function(v, index) { return 'Name'+(index+1)+': '+v; }) .join('\r'); },1); }); Working Fiddle The timeout is needed, because the value of the textarea isn't updated until after the paste event. The text is split on...

add additional fields while maintaining input content

javascript,html,forms,textarea

innerHTML returns the HTML structure but it excludes the value property of form elements (such as textarea). Instead, you could create a new element to hold the additional field, then append that element to inputs: function addInput(){ var inpts = document.getElementById("inputs"), inputCounter = Number(document.getElementById("inputCounter").innerHTML), incCount = inputCounter+1, div = document.createElement('div');...

Auto scroll down a TextArea

java,scroll,javafx,textarea

Here is fast demo of what i meant in comment about adding listener to the textRecu. Yep consoleTextArea.textProperty() can't be changed because of a binding. But textRecu has no binding => can be changed and we can add listener to it. import javafx.application.Application; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; import javafx.beans.value.ChangeListener; import...

textarea $_POST into MySQL with PDO

php,mysql,post,pdo,textarea

You're using desc for your column, being a MySQL reserved word without escaping it with ticks. Either rename it to something else like "description", or wrap it in ticks: UPDATE giveawayitem SET name=:name, `desc`=:desc ... http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html Had you used setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION) it would have signaled the syntax error such as:...

Gap around textarea within a table

css,textarea

In your table tr:nth-child(odd) td rule change vertical-align: text-top; to vertical-align: top; jsFiddle example...

Return matching text from textarea on keyup using jquery

jquery,grep,textarea

Try var input = $("#eventText"), output = $("[for=eventText]"), bannedInput = ["test1", "test two"]; input.on("keyup", function (e) { var name = e.target.value.toLowerCase() , match = $.grep(bannedInput, function (value) { return new RegExp(value).test(name) }); if (!!match.length) { output.append( "<br />Please avoid using the following words and/or phrases: " + "<span class=banned>\"" +...

angularJS textAngular input box loses focus after entering text

angularjs,input,focus,textarea,richtextbox

This issue should be fixed in the most recent version, v1.3.0. Issue with same root cause: https://github.com/fraywing/textAngular/issues/468 EDIT: I monitor both github issues and a search for newest textAngular questions, I'm on GMT+13 so you may have to wait a day for a response but I usually get back to...

-webkit- textarea losing top & bottom padding on vertical scrollbar

html,css,textarea,padding,browser-scrollbars

I've tried to think of a workaround, depending on your own hint. You've got it right, but didn't implement it yet. :) I just coded your idea. What I did was to enclose within a wrapper, and setting before and after pseudo elements to just hide the top and bottom...

how to change innerHTML of textarea after typing in it?

javascript,html,textarea

Change innerHTML to value, <textarea id = "textarea">change this</textarea> <div onclick = "change()">click here<div> <script> function change() { document.getElementById( 'textarea' ).value = 'new text'; } </script> a textarea has a value that can be altered, the innerHTML here just sets the initial value....

Textarea with font-size:30px still autozooms when activated on mobile

html,css,mobile,textarea,zoom

Using the iOS developer tools via USB on my iPhone, I can see that your font-size: 30px has gone through. The reason @user1273587 could not see this via Chrome dev tools is because your @media selectors only change the font size on mobile. From my testing, the higher the font...

Whitespace in textarea

php,textarea,whitespace,simple-html-dom

The PHP trim function will do what you need it to. Just change your file_get_contents($url) to file_get_contents(trim($url)) and it should never have that problem.

Understanding of css textarea offsets

html,css,textarea,typography

It turns out it is a bug on Chromium: Cursor line-height bug on inputs CSS uses what is known as half-leading to render lines of text. This is determ­ined by work­ing out the dif­fer­ence between the line-height and the font-size, divid­ing by 2, and then pla­cing the cal­cu­lated amount of...

Why does my script not make new lines using keyup?

javascript,textarea,onkeyup

I'm not sure, if it's possible to achieve exactly what you want (due to the different font size and family), but this snippet is very close to it. function makePreview() { var text = document.getElementById('inputText').value; document.getElementById('outputText').innerHTML = text; } .wrapper { width: 150px; } .wrapper textarea { width: 100%; }...

Print text in html textarea tag

php,html,textarea

The textarea doesn't have a value attribute. You have to put your echo statement in between the tags like this: <textarea id="description" name="description"> <?php echo $row['description'];?> </textarea> ...

How define textarea content on form edit (Symfony2/TWIG)

forms,symfony2,textarea,twig,value

This should work according to the doc. {{ form_widget(edit_form.description, { 'value': 'content'}) }} {{ form_errors(edit_form.description) }} But I've never tested it....

Setting Background of TextArea

css,textarea,javafx-8

You can do this by fetching the content node out of the TextArea and applying the style to it. But it works only after the TextArea is shown on the stage. Usage : Node node = textArea.lookup(".content"); node.setStyle("-fx-background-color: black;"); ...

How to delete a selection of textarea

javascript,textarea

I think this works for you: var text = []; var textarea = document.getElementById('message'); //simple texteditor function edit(tag) { var startPos = textarea.selectionStart; var endPos = textarea.selectionEnd; console.log(startPos); var selectionBefore = textarea.value.substring(0, startPos); var selection = textarea.value.substring(startPos, endPos); var selectionAfter = textarea.value.substring(endPos); var surrounder = selection.replace(selection, "<" + tag +...

Default to original textarea val on Esc

jquery,textarea,keypress,var,revert

You are almost there, the this in var origVal = $(this).val() points to the document element. Use a specific textarea selector. var origVal = $('#textarea').val() Updated Fiddle Also, remove origVal from keydown(function(e, origVal). The global origVal is accessible in keydown. ...

Pointers about resizing text area

javascript,regex,textarea

You can adapt the textarea height to match the scroll height using the clientHeight vs scrollHeight Here is a working copy of your code var text_to_copy = document.getElementById('p1').textContent; var input = document.createElement("textarea"); var holder = document.getElementById("holder"); document.getElementById('p1').onclick = function(){ holder.appendChild(input); input.id = "textarea_id"; input.style.width = "412px"; input.value = text_to_copy.replace(/\s{1,}/g, '...

HTML/CSS Textarea and Div are different height

html,css,css3,textarea

In most browsers, the textarea element has default padding. In Chrome the element has 2px of padding on each side, and in IE/FF it has 1px of padding on each side. You need to remove the padding if you want both elements to have the same height: Updated Example #textarea...

Get the lines from textarea and insert to mysql [closed]

php,mysql,insert,textarea

You have an infinite loop. while($lines) will continue to run as long as $lines evaluates to true, and I'm not seeing anywhere in your code where the control variable($lines) is unset or set to false. I'm also not seeing anywhere that you would benefit from such a while loop, because...

how can I popup a text area using JQuery (nor input neither in another window)?

jquery,html,popup,textarea,smooth

$(function () { $("#trigger").click(function() { $(".text-hidden").toggleClass("text"); }); }); .text-hidden { transform: scaleX(0); transform-origin: 0% 40%; transition: all .5s ease; } .text { transform: scaleX(1); } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <button id="trigger" type="button">CLICK ME</button> <input type="text" class="text-hidden"></input> You can edit in CSS the way you will hide text area. (opacity, scale, transform,...

Can't post textarea with newlines/carriage return on submit

php,html,textarea

Unexpected EOF may occur due to various reasons such as missing parenthesis {, } or missing delimiters ?> or bad if else logic. If everything mentioned above is done right, It shouldn't be a problem to post a text area with new line unless you're using some ajax. If you're...

How do I set these buttons 'id' values to append in the textarea?

javascript,jquery,html,textarea

You can simplify your code considerably using event delegation. Simply add a div around all of your inputs. <div id="letters"> <input type="submit" style="font-family:'wingdings'" value="P" style="width:100%" id="A" /> <input type="submit" style="font-family:'wingdings'" value="L" style="width:100%" id="B" /> <!-- etc --> </div> Then your jQuery would only need one event. $(document).ready(function(){ var txt=$('#txtarea'); $("#letters").on('click','input',function()...

Making a list in HTML from value of textarea

javascript,html,textarea

Alright, here’s the fixed code and below are all the explanations, etc. Full fixed code along with some other improvements function submit(){ var guestName=document.getElementById('text'); var listData=guestName.value.split('\n'); var listContainer=document.getElementById('list'), listElement=document.createElement("ul"); listContainer.appendChild(listElement); var numberOfListItems=listData.length; var listItem; for(var i=0; i<numberOfListItems; ++i){ listItem=document.createElement("li"); listItem.innerHTML=listData[i];...

JavaFX: Get line height of TextArea

css,javafx,textarea

You can find the exact dimensions of the text rendered in the text area, once the stage is shown: @Override public void start(Stage primaryStage) { TextArea area = new TextArea("This is some random very long text"); area.setWrapText(true); area.setPrefWidth(200); area.setMaxWidth(200); area.setStyle("-fx-font: 18pt Arial"); StackPane root = new StackPane(area); Scene scene =...

Add borders into a textarea [closed]

html,css,textarea

You can use a linear-gradient where the background-size is equal to the line-height defined for the textarea, e.g. http://codepen.io/anon/pen/LELJzy textarea { font-size: 16px; width: 80%; height: 200px; color: #fff; line-height: 1.7em; background: linear-gradient(to bottom, #000 98%, #fff 98%); background-size: 1.7em 1.7em; } Whit this approach you don't need an extra...

Keep linebreaks when getting text from tag not not showing up

html,textarea

You will need to encode the inner tags like so: <textarea>&lt;textarea&gt;Hello World.&lt;/textarea&gt;</textarea> In PHP it's simply a matter of running the file source through htmlspecialchars(). A single pass will not alter the output that is displayed in your editor's textarea....

Groovy Swingbuilder: How can i add a scrollpanel to my frame?

groovy,textarea,scrollpane,swingbuilder

Just embed the textAreas in a scrollPane: scrollPane(constraints:gbc(gridx:1, gridy:0, gridwidth:REMAINDER, fill:VERTICAL, insets:[20, 300, 85, 0])) { textArea(id:'liste', "commands:\n" + ml.opList,editable:false) } ...

JSON data not pulling through for textarea input control

javascript,json,html5,textarea,html-input

Textarea hasn't value attribute. You should put content inside tag: <textarea>VALUE HERE</textarea> You should modify last part of your code in: var deviceDesc = divFormGroupOpening + '<label class="col-md-2 control-label" for="deviceDisplay"> Displayed as: </label>' + divOpeningInput + '<textarea id="deviceDesc" class="form-control" name="deviceDesc" data-val="false">' + data.devices[0].deviceDesc + '</textarea>' + '</div></div>'; ...

How can I use jQuery to replace the content of an attribute inside of a textarea?

javascript,jquery,html,html5,textarea

You can wrap textarea content in a jQuery object then use any relevant method to update it, e.g: var $content = $('<div/>').html($('.mapCode').val()); $content.find('area').attr('coords', selection.x1+','+selection.y1+','+selection.x2+','+selection.y2); $('.mapCode').val($content.html()); -DEMO- ...

Asp.net textarea add empty string to the value [closed]

c#,asp.net,webforms,textarea

Just for a proper answer, I'm posting my comment that fixed the issue: <textarea class="form-control" disabled="disabled"><%#Eval("value") %></textarea> The extra spaces were caused by the code indentation, which textareas treat as user-inputed value....

How many characters can “javascript var keyword” store?

javascript,textarea

There is no such limit. The maximum limit i think is gonna be based on the browser or in short browser specific!

Extra line breaks with simple_format

ruby-on-rails,ruby,textarea

I’m going to assume, that because you are wrapping the body content in show.html.erb, that you don’t mind the data in your database but just want to clean it up to present it. Have you tried: <p><%= strip_tags @post.body %></p> Rails API Reference...

Append selected list elements into textarea, add own text

javascript,angularjs,select,textarea

Here's a working jsfiddle doing what you ask. Every time you click on a list element it is appended to the textarea. The main function is a generic directive that you can reuse across controllers: myApp.directive('txtArea', function() { return { restrict: 'AE', replace: 'true', scope: {data: '=', model: '=ngModel'}, template:...

Escaping apostrophies and other characters in text area

php,html,forms,escaping,textarea

Apostrophes have special meaning to SQL, so to get them into the data they need to be "escaped" PHP has a quick function for this that also does some security checks to help prevent your database from getting hacked. $note = mysql_real_escape_string($note); DITTO on moving away from mysql and onto...

Change an HTML input to textarea and copy over all the events

javascript,jquery,html,input,textarea

Do it this way var textbox = $("#textbox"); $("#change").click(function () { $input = $("#textbox") $textarea = $("<textarea id='textarea'></textarea>").attr({ id: $input.prop('id'), name: $input.prop('name'), value: $input.val(), onchange: $input.attr('onchange'), tabIndex: $input.prop('tabIndex') }); $input.after($textarea).remove(); }); $("#changetext").click(function () { $textarea = $("#textbox") $input = $("<input></input>").attr({ id: $textarea.prop('id'), name: $textarea.prop('name'), value: $textarea.val(),...

Adding psuedo elements to