Sullivan Market

a web based full-circle development system



My JavaScript Tutorials - Textbox Auto-Resize

Here's the Javascript:

<SCRIPT LANGUAGE="JavaScript">
<!--
function boxExpand(me)
{
boxValue = me.value.length;
boxSize = me.size;
minNum = 30;
maxNum = 255;

if (boxValue > maxNum)
{
}
else
{
if (boxValue > minNum)
{
me.size = boxValue
}
else
if (boxValue < minNum || boxValue != minNnum)
{
me.size = minNum
}
}
}
//-->
</SCRIPT>

Here's the code to call this JavaScript along with the JavaScript itself:

<HTML>
<HEAD>
<TITLE>Testing Auto Resize</TITLE>

<SCRIPT LANGUAGE="JavaScript">
<!--
function boxExpand(me)
{
boxValue = me.value.length;
boxSize = me.size;
minNum = 30;
maxNum = 255;

if (boxValue > maxNum)
{
}
else
{
if (boxValue > minNum)
{
me.size = boxValue
}
else
if (boxValue < minNum || boxValue != minNnum)
{
me.size = minNum
}
}
}
//-->
</SCRIPT>

</HEAD>
<BODY>

<table><tbody>

<tr>
<td align=right>Firm Name: </td>
<td><INPUT TYPE=TEXT SIZE=30 NAME=girmName value='William M Mercer, Incorporated' onKeypress='boxExpand(this)' onBlur='boxExpand(this)'
onChange='boxExpand(this)'> </td>
</tr>

</tbody></table>

</BODY>
</HTML>

Here is an example:

Name:

Note:: Make sure that, for this example, you place all the files within the same folder.

Back To JavaScript Tutorials

©2012 SullivanMarket.com