C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






Ceate Table Dynamically Using Javascript


Posted Date: 28 Aug 2008    Resource Type: Code Snippets    Category: Javascript

Posted By: Kundan Kumar Sinha       Member Level: Gold
Rating:     Points: 10



The Javascript function takes the value of text box. Using for loop creates the number of rows. Using innerHTML property of Div tag the table is being displayed.

Add the following Javascript function in Head section of your page, between Script tag.


function ShowTable()
{
var show = document.getElementById("table");
var tableHead = "<Table Border='1' width='100%'>";
var tableBottom = "</table>";
var tableBody="";
var j;
j = document.frm1.txtValue.value;
for(var i = 0; i < j; i++){
tableBody = tableBody + "<tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td></tr>";
}
show.innerHTML = tableHead + tableBody + tableBottom ;
}


Add the following code in the body section of your page.



<form name="frm1">
Number of Rows: >input type="text" name="txtValue">
</form>
<input type=button name="shwTable" value="Show Table" onClick="javascript:ShowTable();">
<div id="table"></div>





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Ceate Table Dynamically Using Javascript  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Get and Set position of a control using Javascript
Previous Resource: Automatic Reloading Page
Return to Discussion Resource Index
Post New Resource
Category: Javascript


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

budget conference call

Contact Us    Privacy Policy    Terms Of Use