How to add the new line in textarea using javascript - html

I have the textarea "write_t". I use following code to change the value of textarea. The problem is '
' does not help me to add the new line. What do I wrong?
var el =document.forms[0].write_t;
el.value=el.value+'
'+k+" some text";

Use \n to add a new line.
var el =document.forms[0].write_t;
el.value=el.value+'
'+k+"\nsome text";

Related

How to shift last word of paragraph to next line without using any tag because content is coming dynamic

My content is coming dynamically, and content is in "p" tag i want last word of paragraph should be shifted to next line.Without adding "span" or any other tag. Is there any css ??
I think the best solution is use JavaScript. I wrote a pice of code with jQuery to accomplish your task.
https://codepen.io/Czeran/pen/yoXGVb
$(document).ready(function() {
var text = $('p').html();
var splitedText = text.split(" ");
splitedText.splice(splitedText.length-1, 0, '<br>');
var joinedText = splitedText.join(" ");
$('p').empty();
$('p').html(joinedText);
});
Unfortunatelly I don't know any CSS or HTML way to do it.

Is it possible to add HTML in a CSS code?

I know you can add CSS in an HTML code, but what I want to know is that is it possible to do the opposite? Because there's something I want to add a class to, but it only has a custom CSS box.
EDIT:
<div class="thing2"></div>
Fiddle - What I wanna try to do here is to make the ".thing2" appear by only putting codes on the css box and not adding the code above in the html box. Just wanted to see if it's even possible.
you can use a function (javascript) like
function myfunc()
{
var something = document.getElementById("ElementID");
something.className = something.className + " newclass";
}
then just call it
No, but you can do it using JavaScript:
var element = document.getElementById("elementId");
element.className = element.className + " newclass";
Hope this helps spark some ideas!

How to cancel automated encoding for img.src?

The 'src' property of an image is encoded when assigned. Is it possible to avoid it?
Example: http://jsfiddle.net/GqQKv/
var img = new Image();
img.src ='http://example.com/whatever?s=Hampshire 123&co=USA'
console.log('src', img.src); // instead of spaces we have %20
ThanksALot();
Just decode it using decodeURI(uri).
That would be console.log('src', decodeURI(img.src));.
Updated FIDDLE

DefaulTextFormat in INPUT TextField

Here's my Code
var format:TextFormat=new TextFormat();
var text:TextField=new TextField();
text.border=true;
text.width=400;
text.multiline=true;
text.wordWrap=true;
text.type=TextFieldType.INPUT;
text.background=true;
text.text="Some text"; // Bold doesn't works with this line
format.bold=true;
text.defaultTextFormat=format;
I can't format text in INPUT textfield when it isn't EMPTY.How i can solve this problem or what is my mistake?
The problem is in defaultTextFormat. As reference says it
specifies the format applied to newly inserted text, such as text
entered by a user or text inserted with the replaceSelectedText()
method.
Try to use a text.setTextFormat(format); instead.
Try to call setTextFormat, you may see this post
text.defaultTextFormat=format;
text.setTextFormat(format);
First set defaultTextFormat, then set text.
format.bold=true;
text.defaultTextFormat=format;
text.text="Some text"; // Should now be bold

changing the size of textarea using setsize

In actionScript,am trying to change the text area using setSize()here is the code..please help me
var prbDesc_txt:TextArea = new TextArea();
prbDesc_txt.text = "Hello world!";
reportAProblemPopUp.addChild(prbDesc_txt);
reportAProblemPopUp.prbDesc_txt.setSize(100,100);
Here am trying to add the textarea to reportAProblemPopUpmc.
Instead of:
reportAProblemPopUp.prbDesc_txt.setSize(100,100);
remove the reportAProblemPopUp and just reference it directly:
prbDesc_txt.setSize(100,100);
Otherwise you need to use getChildByName() on your reportAProblemPopUp if you want to reference it the way you were thinking of.