Creating A Dynamic Table in Javascript
<!DOCTYPE html > <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Dynamic table</title> </head> <script language="javascript"> function getVal() { //alert("hello") var val=document.frm.txt1.value var str="<table border='2'>" +"<tr>" +"<th><font color='blue' size='2'>Item 1</font></th>" +"<th><font color='blue' size='2'>Item 2</font></th>" +"<th><font color='blue' size='2'>Item 3</font></th>" +"</tr>" var b=0; while(val>0) { str=str+"<br />" +"<tr>" +"<td><input type='text' name='jtext"+ ++b +"' /></td>" +"<td><input type='text' name='jtext"+ ++b +"' /></td>" +"<td><input type='text' name='jtext"+ ++b +"' /></td>" +"</tr>"; val--; } str=str+"</table>"; document.getElementById("spn").innerHTML=str; } </script> <body> <center> <h3>Dynamic table creation Example</h3> <form name="frm"> <input type="text" size="20" name="txt1"> </br></br> <input type="button" value="ok" name="okbtn" onclick='getVal()'> </form> <p> <span id="spn"></span> </center> </body> </html>
 
 



 

Latest Tutorial


Most Visited Tutorial