textarea

ASP.NET MVC - How can I set the Default Value in a Strongly Typed TextArea?

冷暖自知 提交于 2019-12-01 09:09:31
问题 I'm trying to make a TextArea have a default value. <%: Html.TextAreaFor(Function(model) model.Description, 5, 10, New With {.Value = "Description: "})%> This works properly in a TextBoxFor but doesn't work in a TextAreaFor Am I missing something very obvious? 回答1: You can specify the value for Description property in the controller action when creating the model, and pass that model to the View: public ViewResult Create() { var model = new MyPageModel() { Description = "Description: "; }

Reset textarea height in javascript

筅森魡賤 提交于 2019-12-01 08:48:55
I have a textarea (auto resizing) and I want to clear all of its contents including its height. So far I've tried: document.getElementById('textarea').value = ''; And : document.getElementById('textarea').attribute('rows','1'); But both doesn't work. EDIT : I use autosize.js with this : <textarea id="post" rows="1" title="Write something..." name="posttxt" placeholder="Write something..." role="textbox" autocomplete="off"></textarea> You could use setAttribute to reset style attribute added automatically during the resize : document.getElementById('reset').onclick = function(){ var textarea =

keep textarea input format after using mysql_real_escape_string to store

左心房为你撑大大i 提交于 2019-12-01 08:01:22
I am using php5.3.6 and mysql 5.1.56 and CodeIgniter. Here is what I did. Input some text in textarea, something like this: what's this? I'm bob. $string = $_POST['name']; $insertdata = mysql_real_escape_string($string); Insert $insertdata into database. It shows "what\'s this?\n\n\nI\'m bob."(without double quotes) in the table. Query the data stored in database, use stripslashes on it and then put it back to the textarea. It shows "what's this?nnnI'm bob."(without double quotes) in the textarea. My questions are: In step 4, shouldn't it be "what\'s this?\n\n\n I\'m bob." stored in the table?

How to save Textarea input after convert line breaks as BR in SQL

淺唱寂寞╮ 提交于 2019-12-01 07:47:49
I use ckeditor in admin panel but in user submit form use simple textbox so user can input text and submit. Problem is when user enter text in textarea with Line Breaks it saves as it in SQL. I want to add BR after each line in sql. For Example User Submits: ![F.R.I.E.N.D.S.: (F)ight for you. (R)espect you. (I)nvolve you. (E)ncourage you. (N)eed you. (D)eserve you and (S)tand by you.][1]![SCREENSHOT oF DB SAVE][2] got saved in DB as it with next line showing in output. But I want to save in DB as: F.R.I.E.N.D.S.:<br /> (F)ight for you.<br /> (R)espect you.<br /> (I)nvolve you.<br /> (E

Reset textarea height in javascript

时间秒杀一切 提交于 2019-12-01 07:20:23
问题 I have a textarea (auto resizing) and I want to clear all of its contents including its height. So far I've tried: document.getElementById('textarea').value = ''; And : document.getElementById('textarea').attribute('rows','1'); But both doesn't work. EDIT : I use autosize.js with this : <textarea id="post" rows="1" title="Write something..." name="posttxt" placeholder="Write something..." role="textbox" autocomplete="off"></textarea> 回答1: You could use setAttribute to reset style attribute

Show separation between newlines in textarea

邮差的信 提交于 2019-12-01 07:12:42
问题 I would like to have the visual representation of an HTML5 <textarea> tag indicate when there are 'hard' newlines as opposed to wrapping. For example, given the text: Hello, world\n How are you, and this text wraps to a new line because it's too long.\n But this is a proper new line. I would like to have some visual indication of the lines separated by newlines such as white-space: Hello world How are you, and this text wraps to a new line because it's too long. But this is a proper new line.

How to save Textarea input after convert line breaks as BR in SQL

一个人想着一个人 提交于 2019-12-01 05:49:43
问题 I use ckeditor in admin panel but in user submit form use simple textbox so user can input text and submit. Problem is when user enter text in textarea with Line Breaks it saves as it in SQL. I want to add BR after each line in sql. For Example User Submits: ![F.R.I.E.N.D.S.: (F)ight for you. (R)espect you. (I)nvolve you. (E)ncourage you. (N)eed you. (D)eserve you and (S)tand by you.][1]![SCREENSHOT oF DB SAVE][2] got saved in DB as it with next line showing in output. But I want to save in

Javascript : How to get the last two characters typed into a textarea?

筅森魡賤 提交于 2019-12-01 05:38:55
问题 What is the best way to grab the last two characters typed into a textarea box? I need the last 2 characters typed NOT the last two characters of the overall string. Appreciate the help! 回答1: Here's a demo of doing it with jQuery, while displaying the last two characters that were entered: http://jsfiddle.net/Ender/5gUHb/ And the source: var keys = []; $('#target').keypress(function(e) { keys.unshift(e.which); update(); }); function update() { $('#last') .prepend($('<li/>').text(String

Scroll without a scrollbar

て烟熏妆下的殇ゞ 提交于 2019-12-01 05:27:28
问题 Sample form: <!DOCTYPE html> <html> <head> <title></title> <style type="text/css"> * {font:13px arial; color:white;} body {background:black;} label {display:inline-block; width:50px;} input, textarea {margin:0; border:1px solid red; padding:0; background:green;} textarea {width:300px; height:100px;} </style> </head> <body> <form action="#"> <div><label for="entry_0">Name</label><input type="text" id="entry_0"></div> <div><label for="entry_1">Email</label><input type="text" id="entry_1"></div>

How do you programmatically move the caret of a Flex TextArea to the end?

徘徊边缘 提交于 2019-12-01 05:21:27
I'm trying to move the caret in a Flex TextArea to the end after appending some text from my code. I've looked through the reference documentation for TextArea and its underlying TextField but it appears there is no method provided to handle this. One approach I've tried is to set focus to the text area and dispatch a KeyUp KeyboardEvent with the event's key code set to the "End" key, but this doesn't work. Any ideas on how to do this? Thanks. Try this textArea.selectionBeginIndex = textArea.length; textArea.selectionEndIndex = textArea.length; For people looking for the Spark component way to