Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you use a loop to regenerate a formatted table??

Status
Not open for further replies.

jeremyhache

Programmer
Sep 30, 2002
19
0
0
US
Is there a way to create a loop in javascript that will loop html code? I have a table on a screen to be printed, and it's formatted to fit perfectly on one printed page. When the page loads, I want it to be able to create additional pages based on a variable from the previous page, let's say, "Number_of_Boxes". I can't just have it print multiple times, the pages will vary slightly. For instance, the first page should have a variable that equals 1, the second 2, and so on, until it equals the "Number_of_Boxes" variable. Can you imbed html within javascript like that, I'm pretty new to the whole thing. Thanks in advance!!!

 
function checkPage(num_boxes)
{
for (var cnt=0 ; cnt < num_boxes ; cnt++)
{
if (document.getElementById(&quot;pageNum&quot;) != null)
var _currPage = document.getElementById(&quot;pageNum&quot;).value +1 ;

document.write(&quot; Current page No : &quot; + _currPage );
// put the content of Table here using document.write
//Update the page number that is hidden field

}

}

However it assumes that you have a hidden text value _currPage that stores the current page number and num_boxes is the maximum value that need to be checked with current page number. You need to call the current function on page load.
Hope it will help [bigcheeks] Experience teaches slowly and at the cost of mistakes [pipe]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top