# Dynamically generate table from text boxes

**URL:** https://forum.kirupa.com/t/dynamically-generate-table-from-text-boxes/199018
**Category:** flash
**Created:** [August 30, 2006, 4:10pm UTC](https://forum.kirupa.com/t/dynamically-generate-table-from-text-boxes/199018 "2006-08-30T16:10:29Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![schmichael](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@schmichael](https://forum.kirupa.com/u/schmichael)
#### Post date: [August 30, 2006, 4:10pm UTC](https://forum.kirupa.com/t/dynamically-generate-table-from-text-boxes/199018/1 "2006-08-30T16:10:29Z")

</div>

Hiya, I’m looking at making a table from dynamically generated text boxes that will adapt their size so the information that is passed to them will fit. the table needs to be 5 columns wide and 10 rows deep.  
I’ve tried doing it by generating each row seperately:  
ActionScript Code:  
[FONT=Courier New][LEFT][COLOR=#808080]_//x Positions for columns_[/COLOR]  
[COLOR=#000000] **var** [/COLOR] x1:[COLOR=#0000ff]Number[/COLOR] = [COLOR=#000080]0[/COLOR];  
[COLOR=#808080]_//0_[/COLOR]  
[COLOR=#000000] **var** [/COLOR] x2:[COLOR=#0000ff]Number[/COLOR] = [COLOR=#000080]90[/COLOR];  
[COLOR=#808080]_//1_[/COLOR]  
[COLOR=#000000] **var** [/COLOR] x3:[COLOR=#0000ff]Number[/COLOR] = [COLOR=#000080]280[/COLOR];  
[COLOR=#808080]_//2_[/COLOR]  
[COLOR=#000000] **var** [/COLOR] x4:[COLOR=#0000ff]Number[/COLOR] = [COLOR=#000080]530[/COLOR];  
[COLOR=#808080]_//3_[/COLOR]  
[COLOR=#000000] **var** [/COLOR] x5:[COLOR=#0000ff]Number[/COLOR] = [COLOR=#000080]800[/COLOR];  
[COLOR=#000000] **function** [/COLOR] createRowCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#0000ff]for[/COLOR] [COLOR=#000000]([/COLOR]i=[COLOR=#000080]0[/COLOR]; i\<[COLOR=#000080]5[/COLOR]; i++[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]  
rows = i+[COLOR=#000080]1[/COLOR];  
[COLOR=#000000] **var** [/COLOR] xPos = [COLOR=#000000][[/COLOR][COLOR=#ff0000]“x”[/COLOR]+COLOR=#000000[/COLOR][COLOR=#000000]][/COLOR]  
[COLOR=#000000] **var** [/COLOR] yPos = totalRowsHeightCOLOR=#000000[/COLOR]  
[COLOR=#0000ff]this[/COLOR].[COLOR=#0000ff]createTextField[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000][[/COLOR][COLOR=#ff0000]“my\_txt”[/COLOR]+COLOR=#000000[/COLOR][COLOR=#000000]][/COLOR], [COLOR=#000080]1[/COLOR], xPos, yPos, [COLOR=#000000][[/COLOR][COLOR=#ff0000]“x”[/COLOR]+COLOR=#000000[/COLOR][COLOR=#000000]][/COLOR]-[COLOR=#000000][[/COLOR][COLOR=#ff0000]“x”[/COLOR]+COLOR=#000000[/COLOR][COLOR=#000000]][/COLOR][COLOR=#000000])[/COLOR];  
[COLOR=#0000ff]this[/COLOR][COLOR=#000000][[/COLOR][COLOR=#ff0000]“my\_txt”[/COLOR]+COLOR=#000000[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#0000ff]multiline[/COLOR] = [COLOR=#000000] **true** [/COLOR];  
[COLOR=#0000ff]this[/COLOR][COLOR=#000000][[/COLOR][COLOR=#ff0000]“my\_txt”[/COLOR]+COLOR=#000000[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#0000ff]wordWrap[/COLOR] = [COLOR=#000000] **true** [/COLOR];  
[COLOR=#0000ff]this[/COLOR][COLOR=#000000][[/COLOR][COLOR=#ff0000]“my\_txt”[/COLOR]+COLOR=#000000[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#0000ff]text[/COLOR] = [COLOR=#ff0000]"I am text box "[/COLOR]+COLOR=#000000[/COLOR];  
[COLOR=#000000]}[/COLOR]  
[COLOR=#000000]}[/COLOR]  
[COLOR=#000000] **var** [/COLOR] rows:[COLOR=#0000ff]Number[/COLOR] = [COLOR=#000080]3[/COLOR];  
[COLOR=#000000] **function** [/COLOR] totalRowsHeightCOLOR=#000000[/COLOR]:[COLOR=#0000ff]Number[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#000000] **var** [/COLOR] totalHeight:[COLOR=#0000ff]Number[/COLOR] = [COLOR=#000080]0[/COLOR];  
[COLOR=#0000ff]for[/COLOR] [COLOR=#000000]([/COLOR]i=[COLOR=#000080]0[/COLOR]; i\<rows; i++[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#808080]_//trace(“i”);_[/COLOR]  
totalHeight += [COLOR=#0000ff]this[/COLOR][COLOR=#000000][[/COLOR][COLOR=#ff0000]“my\_txt”[/COLOR]+COLOR=#000000[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#0000ff]height[/COLOR];  
[COLOR=#808080]_//trace(“mytxt1”+this[“my\_txt”+1].height)_[/COLOR]  
[COLOR=#000000]}[/COLOR]  
[COLOR=#808080]_//trace(“TOTAL HEIGHT”);_[/COLOR]  
[COLOR=#0000ff]return[/COLOR] totalHeight;  
[COLOR=#000000]}[/COLOR]  
[/LEFT]  
[/FONT]

and haven’t finished yet. i was wondering if anyone has come across the solution to my problem before.  
Thanks for any help,  
Schm

UPDATE-

I’ve just realised that I need to specify the height of the text box before it can be created, Is there any way that I can create a text box without specifying the height as this will vary depending on the content. The only way i can think is to use a fixed width font. Any ideas?

Cheers!  
Schm
