By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,842 Members | 2,440 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,842 IT Pros & Developers. It's quick & easy.

How do I set the value between the TEXTAREA tags?

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.