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 !




Displaying Data randomly


Posted Date: 29 Aug 2008      Total Responses: 2

Posted By: anand kumar       Member Level: Silver     Points: 1


HI Guys,

Can anybody help regarding requirement like i need to display data dynamically in Html table requirement like

STEP1.when ever user press show button ie when the user entered 2 number in textbox and press show button i need to display 2 records ie rows and there have 5 columns using javascript. how i can use my login any code help me .But i needed to get from caching using javascript.

<script language="javascript">
function ShowTable()
{
var show = document.getElementById("table");
var tableHead = "<Table Border='1'>";
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 ;
}
</script>
</head>

<body>
<form name="frm1" method="post">
<p>Enter Number of Rows
<input type="text" name="txtValue" >
</form>
<p>
<input type=button name="print" value="Show Table" onClick="javascript:ShowTable();" id="Button1">
</p>
STEP2. But i needed to keep those 5 columns its display its sequentially displaying requirement like randomly should display keeping lile all 5 elements in array i need like after i need to display in descending order those elements .this is requirement

Regards
ANAND




Responses

Author: Kundan Kumar Sinha    08 Sep 2008Member Level: GoldRating:     Points: 6
Hi,

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>


Regards,
Kundan



Author: Kundan Kumar Sinha    08 Sep 2008Member Level: GoldRating:     Points: 6
-


Post Reply
You must Sign In to post a response.
Next : doubt to add entire column value to a textbox in vb.net
Previous : Checkbox in listview
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

masks masks masks

Contact Us    Privacy Policy    Terms Of Use