Script Categories













Forms >>> Expanding Textbox.

Automatically expands the size of a textbox to fit all of the entered text.

LastName:

Add the below code to the <body> section of your page:

<SCRIPT LANGUAGE="JavaScript">
/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin
function call_me(max_length) {
if((document.form1.mybox.value == null ) || (document.form1.mybox.value == "" )) document.form1.mybox.size = size;
if((document.form1.mybox.value.length >= size)&&(document.form1.mybox.value.length <= max_length)) document.form1.mybox.size = document.form1.mybox.value.length + 1;
else document.form1.mybox.size = size;
}
//  End -->
</script>
<form name="form1">
LastName: <input type="text" style="font-family: Terminal" name="mybox" maxlength="30" size="10" onFocus="setInterval('call_me(document.form1.mybox.maxLength)', 1)">
<!--/style needs to be a font that has a fixed size attribute like TERMINAL/-->
</form>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var size = document.form1.mybox.size; //Global Variable keeps original size
//  End -->
</script>

JavaScript Editor Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.



Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!).




©