473,397 Members | 2,033 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,397 software developers and data experts.

Expanding Textbox

Is there a way to make an autosized textbox relative to the content,
here is my attempt:
<script type="text/javascript">
function checkHeight(el){
var newrows=Math.round(Form.Element.getValue(el).lengt h/30);
el.rows=(newrows>0) ? newrows : 1;
}
</script>
<textarea style="font-size:14px;font-family:Lucida Grande, Arial,
Helvetica, sans-serif" id="description" rows="1" cols="30"
onkeydown="checkHeight(this);"></textarea>
<input type="button" onclick="checkHeight($('description'))"
value="test" />
I just wish there was a way to get the scrollheight of the text(rather
than the height of the textbox)

Dec 3 '05 #1
1 2385
Here is another shot at it:
<!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>Expanding Textbox</title>
<script src="scriptaculous/prototype.js"
type="text/javascript"></script>
<style type="text/css" media="screen">
#description, #description-ghost{
font-size:14px;
font-family:Lucida Grande, Arial, Helvetica, sans-serif;
width:300px;
padding:4px;

}
#description-ghost{
width:280px;
}
</style>

</head>

<body>
<script type="text/javascript">
function checkHeight(el){
var ghost=$('description-ghost');
var content=Form.Element.getValue(el);

content = content.replace ( /\ \ /g, "&nbsp;&nbsp;" ) ;
content = content.replace ( /\&nbsp;\ /g, "&nbsp;&nbsp;" ) ;
ghost.innerHTML=content;
ghost.style.display='block'

var h=Element.getHeight(ghost);
ghost.style.display='none'
if(h>10) el.style.height=h+"px"

}
</script>
<textarea id="description" onkeyup="checkHeight(this);"></textarea>
<div id="description-ghost"
style="display:none;font-size:14px;font-family:Lucida Grande, Arial,
Helvetica, sans-serif"></div>
</body>
</html>

in********@gmail.com wrote:
Is there a way to make an autosized textbox relative to the content,
here is my attempt:
<script type="text/javascript">
function checkHeight(el){
var newrows=Math.round(Form.Element.getValue(el).lengt h/30);
el.rows=(newrows>0) ? newrows : 1;
}
</script>
<textarea style="font-size:14px;font-family:Lucida Grande, Arial,
Helvetica, sans-serif" id="description" rows="1" cols="30"
onkeydown="checkHeight(this);"></textarea>
<input type="button" onclick="checkHeight($('description'))"
value="test" />
I just wish there was a way to get the scrollheight of the text(rather
than the height of the textbox)


Dec 5 '05 #2

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

Similar topics

1
by: Jeffrey Kilpatrick | last post by:
I have a SQL 6.5 database that we parse some data into everyday using an access program. All this was devises and setup by a programmer that I can't get in contact with anymore and it has actually...
4
by: David | last post by:
It's sad to say, but when using the AOL web site, like to send an email, they have a nifty capability such that when a window is resized, the textarea where the message is input expands not only...
4
by: erikd | last post by:
I'm using an expanding tree menu based on the design from Dieter Bungers GMD (www.gmd.de) and infovation (www.infovation.de) named displayToc.js. The problem is that the script isn't working...
1
by: Bhiksha Raj | last post by:
Hi, I created an expanding menu on one of the frames in my webpage using code I got from http://www.dynamicdrive.com/dynamicindex1/navigate1.htm I have embedded the code (with minor...
2
by: Deano | last post by:
I have a textbox on a report that show the contents of a note field which stores Memo data. Quite alot of text can be typed by the user here but if it exceeds a certain amount the textbox does not...
5
by: Madhanmohan S | last post by:
Hi All, I am having a server TextBox control in my page. Size of the TextBox is relative(i.e. 50%).When i view this page in IE, I observed a behaviour which looks odd to me. If the size of the...
6
by: Jack | last post by:
Hello, I would like some advice on how to disable the behavior of treeviews to expand and collapse when double clicked upon, but still allow the user to use the plus and minus on each node. ...
1
by: Donald Grove | last post by:
My client wants to print reports that include a memo field. Sometimes there is just a little data there, and sometimes it is quite long. Is there code to resize a report control bound to a memo...
13
Chrisjc
by: Chrisjc | last post by:
I am in need of an expanding and collapsing code… The goal is To be able to click a PICTURE IMAGE and expand to show information Reason for this is I have 3 TABLES of information of about ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.