473,396 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How do I set the value between the TEXTAREA tags?

Hi,

If my variable contains

var v = "Hi<BR/>there<BR/>";

and attempt to set the value of my textarea like so:

dojo.byId("appEditForm:txtDesc").value = v;

I actually see the "<BR/>" tags displayed on the screen. I don't want
this -- preferring to see line breaks. What is the proper way to set
the HTML between TEXTAREA tags?

Thanks, - Dave
Jul 21 '08 #1
5 3200
On Jul 21, 10:32*am, laredotornado <laredotorn...@zipmail.comwrote:
Dave,
the best way to do this is with PHP/AJAX. But this may not be your
best option depending on what you're doing. I use the below code
becasue its simple, but there are many frameworks that can squeeze
this done to one line of code.
function ajxPost(){
var ajaxRequest;

try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// ajax function
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
var ajaxDisplay = document.getElementById('textarea-id');
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
}
var queryString = "?variable=" + variable+ "&bankid=" + bankid;

ajaxRequest.open("GET", "php-file-with-content.php" + queryString,
true);
ajaxRequest.send(null);
}

Hi,

If my variable contains

var v = "Hi<BR/>there<BR/>";

and attempt to set the value of my textarea like so:

dojo.byId("appEditForm:txtDesc").value = v;

I actually see the "<BR/>" tags displayed on the screen. *I don't want
this -- preferring to see line breaks. *What is the proper way to set
the HTML between TEXTAREA tags?

Thanks, - Dave
Jul 21 '08 #2
On Jul 21, 1:32*pm, laredotornado <laredotorn...@zipmail.comwrote:
Hi,

If my variable contains

var v = "Hi<BR/>there<BR/>";

and attempt to set the value of my textarea like so:

dojo.byId("appEditForm:txtDesc").value = v;

I actually see the "<BR/>" tags displayed on the screen. *I don't want
this -- preferring to see line breaks. *What is the proper way to set
the HTML between TEXTAREA tags?

Thanks, - Dave
Theres no way to do it, its like asking the proper way to set an
iframe inside a textarea...
theres a reason its called TEXTAREA!

if you only want to convert <br/to \n, then you should do something
like,
dojo.byId("appEditForm:txtDesc").value = v.replace(/<br\/>/ig,"\n");
Jul 21 '08 #3
On Jul 21, 10:32*am, laredotornado <laredotorn...@zipmail.comwrote:
Now that I think about it, I do not believe this will work for a text
area. It may not be necessary to put a text area here, and you may
want to use a div instead. this all depends on exactly what you are
doing.

Sorry i could not be more help, but I'm very very new to JS myself and
I have trouble doing the easiest things.

>
If my variable contains

var v = "Hi<BR/>there<BR/>";

and attempt to set the value of my textarea like so:

dojo.byId("appEditForm:txtDesc").value = v;

I actually see the "<BR/>" tags displayed on the screen. *I don't want
this -- preferring to see line breaks. *What is the proper way to set
the HTML between TEXTAREA tags?

Thanks, - Dave
Jul 21 '08 #4
I actually see the "<BR/>" tags displayed on the screen. *I don't want
this -- preferring to see line breaks. *What is the proper way to set
the HTML between TEXTAREA tags?
Then, use the new line feed ("\n") instead of "<BR/>".

Hope, this will helps you.

Jul 22 '08 #5
Suhas Dhoke wrote:
>I actually see the "<BR/>" tags displayed on the screen. I don't want
this -- preferring to see line breaks. What is the proper way to set
the HTML between TEXTAREA tags?

Then, use the new line feed ("\n")
There is no character with that name. There is the Line Feed (LF) character
(escape sequence: "\n") and the Carriage Return (CR) character ("\r"). Both
are used for creating a new line: "\r\n" is used on WinDOS, "\n" is used on
Unices, and "\r" is used on Mac OS up to version 9, among others.
Therefore, it is probably best to use the escape sequence "\r\n" as it
satisfies all conceivable markup parsers, including standards-compliant ones.
instead of "<BR/>".
<BR/is not likely to be Valid markup anyway. If it should be HTML, then
it should be <BR>, <Br>, <bRor <br(else it would be equivalent to
"<BR>&gt;". If it should be XHTML (which should only be used on today's Web
instead of HTML when absolutely necessary), then it must be <br/>, <br /or
<br></br(XHTML is case-sensitive), whereas the second form is deemed
"HTML-compatible" (because many of not most markup parsers do not implement
the HTML SHORTTAG feature properly).
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Jul 22 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: megha | last post by:
Hi all I am adding signature in textarea which is stored as text in database now if i add html tags to it and later retrieve it in textarea it shows all tags of html but not their function. How...
6
by: wperry1 | last post by:
I am writing a small database utility to catalog all of my favorite ASM/JS/VBS... functions and scripts on an asp page. Everything is going smoothly except for one thing that I can't quite seem to...
2
by: Michael | last post by:
Question 1 ---------------- I am writing an advanced BBCode system for my forums and I would like to be able to find where the cursor was positioned last in the text so I could insert the BBCode...
5
by: joelbyrd | last post by:
Didn't know exactly where to post this, but: How do I get line breaks in a textarea? I'm pulling text from a database, and this text definately has line breaks in it, because I replaced all the...
2
by: xhe | last post by:
I met a very headache problem in javascript, I think this might be difference between IE and NS / Safari. I have a text area <form> <textarea name='tex1' onkeyup='displayit();'></textarea>...
6
by: Cecil Westerhof | last post by:
This is a piece of code from a xslt-file: <xsl:template match="SMS"> <xsl:for-each select='.'> <tr> <td class = "inputDescription"><xsl:value-of select='.' />:</td> <td><textarea class =...
2
by: dennis.sprengers | last post by:
Ik ben bezig met een eigen UBB editor. Als iemand aan het typen is, zorgt CTRL-B voor een \-tag en nogmaals CTRL-B voor een \ tag. Als je eerst een selectie maakt en dan CTRL-B drukt, wordt de...
1
by: nubster21 | last post by:
I would like to split a string of HTML output into an array on textarea tags. Example: <div>Hello this is my content <textarea>foo</textareaand this is also content <b>some bold...
8
by: Floortje | last post by:
Hi, for the past few days now im trying to find some info on how to manipulate textarea's with javascript. Im trying to add content when a certain element is clicked or alter content if another is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.