Anonymous 0

Hello,

Can anyone tell me which is the best solution to create a dynamic text area? I have this code:

<!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=utf-8" />
<title>Teste</title>
<style type="text/css">
#test {
    background: #f90;
    width: 292px;
}
#test textarea {
    width: 278px;
    background: transparent;
    border: none;
    overflow: auto;
}
</style>
</head>
<body>
<div id="test">
<form action="" method="get">
<textarea name="txtArea" cols="" rows=""></textarea>
</form>
</div>
</body>
</html>

What i need is when someone writes a long message, the textarea box should expand automatically, the same for the background of div#test with the color #f90. If possible compatible with all major browsers and xhtml/css w3 validation.

If anyone can help me, i will appreciate a lot, thanks.

Regards

1 answer

2
points

Take a look at this simple JQuery plugin: http://james.padolsey.com/javascript/jquery-plugin-autoresize/

Not the only one, but a beginning.

Answered almost 8 years ago by Roland Schulz
  • That's exactly what I would have recommended :P +1 o.k.w almost 8 years ago