Click to See Complete Forum and Search --> : loop to open window, only opens last
lcscne
10-06-2003, 04:25 PM
function printReports()
{
var studentID
for (i=0; i<document.frmStudentList.elements.length; i++)
{
if(document.frmStudentList.elements[i].type == "checkbox")
{
if(document.frmStudentList.elements[i].checked)
{
studentID=document.frmStudentList.elements[i].name
("DurationRules.htm","ProgressReport","resize=off,titlebar=false,toolbar=no,width=560,height=185")
progrep=open("../Student/PvProgReport.asp?RosterID=303&StudentID="+studentID,"ProgressReport","resize=off,titlebar=false,toolbar=no,width=560,height=185")
}
}
}
}
My problem is that this code only opens the last window in the the loop. I hoped it would open a window per loop. Anyone spot my problem? Thanks
Dimitri
10-06-2003, 05:19 PM
Try this:
var progrep = open("../Student/PvProgReport.asp?RosterID=303&StudentID=" + studentID, "_blank", "resize=off,titlebar=false,toolbar=no,width=560,height=185");
If that doesn't work, try setting the window name as a variable that changes with each iteration. For example:
var foo = 0; // note: place this line OUTSIDE of the loop
var progrep = open("../Student/PvProgReport.asp?RosterID=303&StudentID=" + studentID, "test" + (foo++), "resize=off,titlebar=false,toolbar=no,width=560,height=185");
Dimitri
lcscne
10-08-2003, 02:17 PM
Thanks Dimitri,
Now one more, is there a way to set the x,y position of each window so that I can offset them down and to the right (cascade them)? Their all stacked on top of each other.
Dimitri
10-08-2003, 03:34 PM
use moveTo()
Here's a simple demo to give you an idea of how it works (and make sure you have popup killers disabled in your browser):
<html>
<body>
<script>
var totalWindows = 4;
for (var x = 0; x < totalWindows; x++) {
var foo = window.open("","win" + x,"left=" + (x*210) + ",top=0,width=190,height=100");
foo.document.open();
foo.document.write("Sample Window #" + (x+1));
foo.document.close();
}
function cascade() {
for (var x = 0; x < totalWindows; x++) {
var foo = window.open("","win" + x);
foo.moveTo(x*100,x*30);
foo.focus();
}
}
</script>
<br><br><br><br>
<a href="javascript:cascade()">cascade these windows</a>
</body>
</html>
lcscne
10-08-2003, 03:48 PM
Thanks Dimitri, that works like a charm.