Generating dynamic data using Javascript

Posted by methuselah on Stack Overflow See other posts from Stack Overflow or by methuselah
Published on 2011-12-01T01:48:37Z Indexed on 2011/12/01 1:49 UTC
Read the original article Hit count: 93

Filed under:

Given that I have an array of alphabetical characters:

var qwerty = [['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p'], ['a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l'], ['z', 'x', 'c', 'v', 'b', 'n', 'm']];

How would I present them in three rows like on a conventional keyboard using JS without resorting to something like this:

<input type='button' value='Q' id='bt1'/>
<input type='button' value='W' id='bt2'/>
<input type='button' value='E' id='bt3'/>
<input type='button' value='R' id='bt4'/>
<input type='button' value='T' id='bt5'/>
<input type='button' value='Y' id='bt5'/>
<input type='button' value='U' id='bt7'/>
<input type='button' value='I' id='bt8'/>
<input type='button' value='O' id='bt9'/>
<input type='button' value='P' id='bt10'/>
<br>
<input type='button' value='A' id='bt11'/>
<input type='button' value='S' id='bt12'/>
<input type='button' value='D' id='bt13'/>
<input type='button' value='F' id='bt14'/>
<input type='button' value='G' id='bt15'/>
<input type='button' value='H' id='bt16'/>
<input type='button' value='J' id='bt17'/>
<input type='button' value='K' id='bt18'/>
<input type='button' value='L' id='bt19'/>
<br />
...

Many thanks in advance!

© Stack Overflow or respective owner

Related posts about JavaScript