...

View Full Version : javascript table generator



eden70
11-09-2006, 11:31 PM
Hi there if someone could help i would really apreciate it.I am looking for a table generator that works with prompts. Something like this the first prompt asks How many rows? second prompt How many columns? third prompt Border size fourth prompt Bgcolor and fifth prompt Create table... If someone could help me out with source code i will be very grateful....

rubenbuhr
11-10-2006, 12:45 AM
Well, I sure dislike all those bells when I work with prompts and alerts.
What do you think of this?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD><TITLE>MakeAtable </TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<STYLE type=text/CSS>
*{height:15;width:15}
</STYLE>
<SCRIPT type="text/javascript">
function mktbl(r,c){
document.getElementById('abc').value='';

var stbl='<TABLE BORDER="1">\n <TBODY>\n';
for(j=0;j<r;j++){stbl+=' <TR>\n'; for(i=0;i<c;i++){stbl+=' <TD> @ </TD>\n';}; stbl+=' </TR>\n'}
stbl+=' </TBODY>\n</TABLE>\n';
document.getElementById('def').innerHTML=document.getElementById('abc').value=stbl;
}
</SCRIPT>
<META content="MSHTML 6.00.2900.2963" name=GENERATOR></HEAD>
<BODY>
<TABLE cellpadding=0 cellspacing=0 border=1>
<TBODY>
<TR>
<TD><input type="button" class="bttn" onclick="mktbl(1,1)"></TD>
<TD><input type="button" class="bttn" onclick="mktbl(1,2)"></TD>
<TD><input type="button" class="bttn" onclick="mktbl(1,3)"></TD>
</TR>
<TR>
<TD><input type="button" class="bttn" onclick="mktbl(2,1)"></TD>
<TD><input type="button" class="bttn" onclick="mktbl(2,2)"></TD>
<TD><input type="button" class="bttn" onclick="mktbl(2,3)"></TD>
</TR>
<TR>
<TD><input type="button" class="bttn" onclick="mktbl(3,1)"></TD>
<TD><input type="button" class="bttn" onclick="mktbl(3,2)"></TD>
<TD><input type="button" class="bttn" onclick="mktbl(3,3)"></TD>
</TR>
</TBODY>
</TABLE>
<TABLE BORDER="0">
<TBODY>
<TR>
<TD><textarea id="abc" style="height:300;width:300"></textarea>
</TD>
<TD id="def"></TD>
</TR>
</TBODY>
</TABLE>


</BODY></HTML>


Something gets lost when I paste that inot notepad,
here, have it direct and change the extension to .html



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum