CoderZone.org

Category: >> JavaScript >> Change text box height Bookmark and Share

<< lastnext >>

Snippet Name: Change text box height

Description: May not work on some (older) versions of Internet Explorer.

Set a textarea height to 99% of a table cell, then uses a 1px wide gif to alter the height.

Comment: (none)

Author: CoderZone
Language: JAVASCRIPT
Highlight Mode: JAVASCRIPT
Last Modified: February 27th, 2009

<table><tr>
<td>
<img id="ZZ" align="left" src="spacer.gif" width="1" height="50">
<textarea name="sometext" style="height: 99%;"></textarea>
</td></tr>
</table>
 
 
     <form name="sizer">
     <input type="button" name="up" value="+" onclick="IncImgSize('ZZ',20);"> 
     <input type="button" name="dn" value="-" onclick="DecImgSize('ZZ',20);"> 
     </form>
 
 
 
     // increases height of text box
     function IncImgSize(objectId,newHeight) {
          imgString = 'theImg = document.getElementById("'+objectId+'")';
          eval(imgString);
          oldHeight = theImg.height;
               if(newHeight>0){
                    theImg.height = theImg.height + newHeight;
               }
     }
 
     // decreases height of text box
     function DecImgSize(objectId,newHeight) {
          imgString = 'theImg = document.getElementById("'+objectId+'")';
          eval(imgString);
          oldHeight = theImg.height;
               if(newHeight>0){
                    theImg.height = theImg.height - newHeight;
               }
     }
 
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© coderzone.org | users online: 16