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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pause a FOR loop to allow user to select option in pop-up window

Status
Not open for further replies.

jillallynwilson

Programmer
Apr 14, 2004
21
US
Within my company's Supply Chain Management system I need to allow our customers to select multiple lines from their inventory list to be re-ordered. I can get the code to loop through the checked items, however, it only shows the necessary pop-up window for the last item selected.

I need the loop to pause while the users enters the appropriate quantity and re-order options.

Here is my code so far (NOTE: these pages are built dynamically and there may be 1 item or up to 20 items on a page):
<script language="JavaScript" type="text/JavaScript">
<!--
function submitIt(unid, opt, project, cylno, desc, folio, prodcode, custno)
{
var df = window.document.CylinderDetails;
var newwin;
var count = df.count.value;
count++;
for (var i=1; i < count; i++)
{
            if (document.CylinderDetails["checkbox_" + i].checked)
{
var cylno = document.CylinderDetails["checkbox_" + i].value
if (opt = "ReOrder")
{
newwin = window.open("/Sample2.nsf/(ReOrder)?OpenAgent&UNID=" + unid + "&Ord=" + project + "&CylNo=" + cylno + "&Desc=" + desc + "&FOLIO=" + folio + "&ProdCode=" + prodcode + "&CustNo=" + custno, "reord","width=400,height=450, status=yes,resizable=yes");
newwin.focus();
}
            }       
}
}
</script>

<link rel="stylesheet" type="text/css" href="/style.css">
</head>
<body bgcolor="#FFFFFF" leftmargin="3" topmargin="0" marginwidth="0" marginheight="0">
<form style="margin-top: 0; margin-bottom: 0;" name="CylinderDetails" method="post" action="">
<table width="760" border="0" cellspacing="0" cellpadding="0">
<tr><td>HEADING INFORMATION IS HERE-removed to shorten code</td></tr>

<tr>
<td align="left"><input type="checkbox" name="checkbox_1" value="SD0415100"></td>
ADDITIONAL COLUMNS OF DATA-removed to shorten codetd></tr>

<tr>
<td align="left"><input type="checkbox" name="checkbox_2" value="SD0415200"></td>
ADDITIONAL COLUMNS OF DATA-removed to shorten code</td></tr>

<tr>
<td align="left"><input type="checkbox" name="checkbox_3" value="SD04152100"></td>
ADDITIONAL COLUMNS OF DATA-removed to shorten code</td></tr>

---- code continued - only supplied a sample ------

THANK YOU :eek:) for any help that you can give.

 
The quick-and-dirty solution would be to rename each window as "reord_"+i (rather than just "reord"). Right now, each reorder opens in the same window, which is why you only see that last one. By having the window names be unique, you will get one window for each reorder needed.

Obviously, this could be a bit burdensome as well! I will think on other ways...

--Dave
 
Dave --

THANK YOU for the help - By renaming the window to "reord" + i now I am getting a new window for each item selected. However, your are correct in that it is burdensome.

The best would be if I could not continue in the FOR loop until the parent window is back in focus.

Any additional thoughts are greatly appreciated.

Thank you again.

-- Jill
 
Okay, it took me a while, but you can replace the for-loop with something LIKE a for-loop. Check out this example:

Code:
<html>
<head>
<script>
var newwin, timeoutObject;
var i = 0; [b]//"loop" variable declared globally[/b]
function startUp()
{
 if(i<2) [b]//"loop" conditional[/b]
 {
  newwin = window.open("about:blank","win_"+i);
  wait();
 }
}

function wait()
{
 if(!newwin.closed)
  timeoutObject = setTimeout("wait()",100);
 else
 {
  clearTimeout(timeoutObject);
  i++; [b]//"loop" increment[/b]
  startUp();
 }
}
</script>
</head>
<body>
<input type='button' value='start' onclick='startUp()' />
</body>
</html>

Will something like that work for you?

--Dave
 
Dave --

This solution worked like a charm. THANK YOU SO MUCH FOR YOUR HELP :eek:).


Jill--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top