/    Sign up×
Community /Pin to ProfileBookmark

Dynamic Textbox resize

I have a asp textbox and need to expand the box height with the text that is in. I thought javascript would be best so I didn’t have to refresh the page every time.

Any body have any code that could help me out here. I have tried a few things but nothing has worked.

Thanks to all that reply!

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@SoreheadMar 06.2008 — Something along these lines

[code=html]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Test</title>
<script type="text/javascript">
<!--

function expand(width,height)
{

document.getElementById("text_output").cols = width;
document.getElementById("text_output").rows = height;

}

-->
</script>
</head>
<body>

<form name="test" action="" method="get">
<textarea id="text_output"></textarea>
<input type="button" value="Expand" onclick="expand(30,10);" />
</form>
</body>
</html>
[/code]
Copy linkTweet thisAlerts:
@runswithsizzorsauthorMar 06.2008 — Like that but I need to do it when the text fills the box. Instead of scroll bars I just need the box to expand.
Copy linkTweet thisAlerts:
@runswithsizzorsauthorMar 07.2008 — I need it for a text box as well. I have a text box with multi-line.

Thanks!
Copy linkTweet thisAlerts:
@runswithsizzorsauthorMar 07.2008 — This is what I ended up with. I did it with a textarea but if anyone knows how to do it with a text box with muti-line that would be awesome.

[CODE] function resizeCommentsBox(sender)
{

a = sender.value.split('n');
b = 1;
for (x = 0;x < a.length; x++)
{
if (a[x].length >= sender.cols)
{
b += Math.floor(a[x].length/sender.cols);
}
}
b += a.length;
if (b > sender.rows)
{
sender.rows = b;
}
}[/CODE]
×

Success!

Help @runswithsizzors spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...