473,799 Members | 2,746 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.ro und(Form.Elemen t.getValue(el). length/30);
el.rows=(newrow s>0) ? newrows : 1;
}
</script>
<textarea style="font-size:14px;font-family:Lucida Grande, Arial,
Helvetica, sans-serif" id="description " rows="1" cols="30"
onkeydown="chec kHeight(this);" ></textarea>
<input type="button" onclick="checkH eight($('descri ption'))"
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 2407
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.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"
/>
<title>Expandin g Textbox</title>
<script src="scriptacul ous/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=$('descri ption-ghost');
var content=Form.El ement.getValue( el);

content = content.replace ( /\ \ /g, "&nbsp;&nbs p;" ) ;
content = content.replace ( /\&nbsp;\ /g, "&nbsp;&nbs p;" ) ;
ghost.innerHTML =content;
ghost.style.dis play='block'

var h=Element.getHe ight(ghost);
ghost.style.dis play='none'
if(h>10) el.style.height =h+"px"

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

in********@gmai l.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.ro und(Form.Elemen t.getValue(el). length/30);
el.rows=(newrow s>0) ? newrows : 1;
}
</script>
<textarea style="font-size:14px;font-family:Lucida Grande, Arial,
Helvetica, sans-serif" id="description " rows="1" cols="30"
onkeydown="chec kHeight(this);" ></textarea>
<input type="button" onclick="checkH eight($('descri ption'))"
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
6140
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 run for about five years without a hickup! But just a few days ago our parsing program just stops dead before completing and I did get this error message. "exportaLLdataToSQLifnoerror(): number 3146 Description- odbd- call failed. Can't...
4
10220
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 horizontally, but also vertically, to fill the space. I took a look at their javascripts, but they are quite complex and convoluted since they make use of many of their own functions designed to work with their web site. Does anybody have a...
4
2693
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 properly in Firefox, although it's working without problems in IE 5.5 & 6.0 In Firefox any file which isn't in the same directory isn't found, so the images are missing and the links don't launch. It may be something simple, but I don't have the...
1
2199
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 modification to point to my links) into a frame on my webpage. The problem is that when I open the page on netscape 7,
2
1534
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 expand fully to show what was typed in. CanGrow is set to Yes. What else am I missing? thanks
5
2355
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 Text in the TextBox increases then the size of he text Box also increases. If the size of the text is very small then the TextBox is not increasing in length and it is exactly 50%. Can any one please help me in avoiding this specific problem? ...
6
7394
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. Thanks in advance! Jack
1
1454
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 field, which resizes according to the length of the text string in the memo field?
13
2776
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 400x200… that I want to be able to expand to how much information I put in them…. Just need a code that will cut it off and then OPEN it… So
0
9687
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10488
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10237
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10029
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7567
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6808
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5588
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.