Closed Bug 549278 Opened 11 years ago Closed 10 years ago

Adding lines with DOM to a textarea is not working as expected

Categories

(Core :: DOM: Core & HTML, defect)

1.9.2 Branch
x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: capape_gil, Unassigned)

References

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.9.2) Gecko/20100115 Firefox/3.6 GTB6 (.NET CLR 3.5.30729)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.9.2) Gecko/20100115 Firefox/3.6 GTB6 (.NET CLR 3.5.30729)

I'm trying to fill a text area with new lines. But when I add a new line  CRLF (HTML line terminator for multi-line elements) using DOM, the new line is CR ended.

Then if I post this data to an action, it sends a single line value.

Reproducible: Always

Steps to Reproduce:
1.Save the following code as a html page.
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Insert title here</title>
</head>
<body>
<form  id="form-textarea" method="post" action="">
<textarea id="area" name="area"></textarea>
<input type="button" onclick="enviar()" value="Enviar" />
</form>
<script type="text/javascript">
//<![CDATA[
    function enviar() {
        document.getElementById("area").value="hola\u000d\u000aadios" ;

        alert(escape(document.getElementById("area").value));
    }
//]]>
</script>
</body>
</html>

2. Press button "Enviar"

3.
Actual Results:  
Alert with  hola%0Aadios

Expected Results:  
Alert with  hola%0D%0Aadios
Version: unspecified → 3.6 Branch
Sorry I said CR ended when it's LF ended
See Also: → 384557
Reporter, are you still seeing this issue with Firefox 3.6.13 or later in safe mode or a fresh profile? If not, please close. These links can help you in your testing.
http://support.mozilla.com/kb/Safe+Mode
http://support.mozilla.com/kb/Managing+profiles
Whiteboard: [CLOSEME 2011-2-25]
I'm still seeing it in firefox 3.6.13, windows xp.
Component: General → DOM: Core & HTML
Product: Firefox → Core
QA Contact: general → general
Whiteboard: [CLOSEME 2011-2-25]
Version: 3.6 Branch → 1.9.2 Branch
Newlines in the DOM are always LF only.  So the behavior is correct.
Status: UNCONFIRMED → RESOLVED
Closed: 10 years ago
Resolution: --- → INVALID
Thanks a lot.

It's strange you can send the CRLF in a form with a textarea, but you can't assign it by DOM to a textarea and send it. I'll take it into account.
If you put an LF in a textarea it should become a CRLF when the form is submitted, if you're on Windows.
Sorry.

Last comment, I didn't mention that  I'm using and XMLhttprequest to send data. 
In the application we found the problem we copied data from one textarea to another, and finally we sent the form with ajax.

I believed then it was a problem with textarea. Now I see we have to manage this situations before sending the request. 

My apologies and thanks again.
You need to log in before you can comment on or make changes to this bug.