Passing arrays into a javascript function and the javascript function calling another asp page.

Hi All,

I want to pass an array of StockListIDs into a javascript function that calls an asp page that will add a stock item to a the array id's that are passed into this page.

The problem that I have is that if I can pass the array values absolutely correctly using the below than I could get this working. I am NOT having much luck in doing so. Even if someone can write 2 asp pages that is similar to my asp pages and get the abovementioned functionality correct this would be greatly appreciated.

All the code is below:

I will attach the asp code and show you what is happening in the code:

The 2 comments is what you need to look for:
'Javascript function as shown below(KitIdArray(0)):
'Array of StockListIds(KitIdArray) that are passed into this javascript function below:

Firstly, the caller asp page(viewkitdetailES.asp) the code is below:

<!--#include file="../inc/adovbs.asp" -->
<!--#include file="../inc/std.asp" -->
<!--#include file="../inc/const.asp" -->
<!--#include file="../inc/securitycheck.asp" -->

<html>
      <head>
            <title>
            <% rw BrandName %>
            </title>
<!--#include file="../inc/commonmenuscripts.asp" -->

<table width=<% = ScreenWidth %> border=0 cellpadding=0 cellspacing=0>
            <tr valign=top>
                  <td width=<% = TableSpacing %>>
                        &nbsp;
                  </td>


                  <td width=<% = TableWidth %> class="bodytext">

<!-- main page content -->

            <span class="bodyhead">View Detail of Kits</span><p><p>

<script type="text/javascript" language="JavaScript">
<!--

function submitconfirm(Childid, Parentid,childCount)
{
      if(confirm('Are you sure you want to delete this product from the Kit?')) {
            window.location = '<% =CurrentURL & "?name=" & request("name") & "&type=1&chid=" %>' + Childid + '&id=' + Parentid + '&cc=' + childCount;
      }
}

function addtokit(stockid, kitname, newFlag) {
      var myBars = 'directories=no,location=no,menubar=no,status=no,';
      myBars += 'titlebar=no,toolbar=no';
      var myOptions = 'scrollbars=yes,width=650,height=500,resizeable=no';
      var myFeatures = myBars + ',' + myOptions;
      var openURL = 'addkitproductES.asp?'
      openURL += 'stockid=' + stockid + '&name=' + kitname + '&newflag=' + newFlag
      newWin = open(openURL, 'mydoc', myFeatures);
      newWin.focus();
      newWin.document.close();
}

'Array of StockListIds(KitIdArray) that are passed into this javascript function below:
function addtokit2(KitIdArray, kitname, newFlag) {
      var myBars = 'directories=no,location=no,menubar=no,status=no,';
      myBars += 'titlebar=no,toolbar=no';
      var myOptions = 'scrollbars=yes,width=650,height=500,resizeable=no';
      var myFeatures = myBars + ',' + myOptions;
      var openURL = 'addkitproductES.asp?'
      openURL += 'stockid=' + KitIdArray + '&name=' + kitname + '&newflag=' + newFlag
      newWin = open(openURL, 'mydoc', myFeatures);
      newWin.focus();
      newWin.document.close();
}

function editkitqty(parentid, stockid, kitQty, kitName) {
      var myBars = 'directories=no,location=no,menubar=no,status=no,';
      myBars += 'titlebar=no,toolbar=no';
      var myOptions = 'scrollbars=no,width=240,height=250,resizeable=no,left=400,top=300,screenX=100,screenY=100';
      var myFeatures = myBars + ',' + myOptions;
      var openURL = 'editkitqtyES.asp?'
      openURL += 'parentid=' + parentid
      openURL += '&stockid=' + stockid
      openURL += '&oldqty=' + kitQty
      openURL += '&name=' + kitName
      newWin = open(openURL, 'mydoc', myFeatures);
      newWin.focus();
      newWin.document.close();
}
//-->
</script>

<%
Dim KitArray(50)
Dim KitIdArray(50)

Dim rsStockItemBelongToKitES
Dim sqlStockItemBelongToKitES
Dim rsnkitSummary
Dim EditKitName
Dim sqlnkitSummary
Dim HowManyParentIDCount

StockID = request("stockid")

pdebug StockID

if request("new") then

      if security(sClientAdmin) then
            rw "<p class=""bodytext"">You must add at least 1 component to the Kit otherwise the Kit will not be created<P>"

            rw "<a href=""javascript:addtokit(" & StockID & ",'" & kitname & "','" & true & "')"">Add a new component</a><p>"
      end if
else
      set dbconn = Server.CreateObject("ADODB.Connection")
      dbconn.open ODBCsource
      if request("type") = 1  and security (sPowerUser) then       ' delete ID first

            delsqlkit = "DELETE FROM Kits WHERE parentid = " & request("id") & _
                  " AND ChildID = " & request("chid")
            pdebug delsqlkit
            dbconn.execute(delsqlkit)
            Audit request("id"), "Kits ChildId " & request("chid") & " Deleted"            ' log event

      else
            Session("KitID") = request("id")
      end if

      if request("cc") = 1 then ' last item deleted, no point showing kit detail - kit no longer exists

            'response.redirect("/admin/kitssummaryES.asp")
            response.redirect("/admin/viewkitdetailES.asp")
      else
            sqlnkitSummary = "SELECT * FROM nkitSummary WHERE ClientID = " & ClientID
            'kitListID = Session("KitID")
            
            PDebug sqlnkitSummary
            response.flush

            set rsnkitSummary = Server.createObject("ADODB.Recordset")
            rsnkitSummary.open  sqlnkitSummary , dbconn, adUseClient, adLockreadonly, adCmdText
                        
            'get on with it
            if rsnkitSummary.eof then
                        
                  PrintError "There are no products in this kit.<p>"
            else
                  'First loop to get the ParentID for a Kit
                  do while not rsnkitSummary.eof
                        EditKitName = rsnkitSummary("StockName")
                        pdebug "kitName= " & EditKitName
                        'display kit name
                        rw "<table cellspacing=2 cellpadding=2 border=0>"
                        rw "<tr valign=top>"
                        rw "<td> <span class=""bodyhead"">Kit Name:</span></td>"
                        rw "<td> <span class=""bodyhead"">" & EditKitName & "</span></td>"
                        rw "</tr>"
                        rw "</table>"
                        kitListID = rsnkitSummary("ParentID")
                        PDebug "kitID= " & kitListID
                        'Takes care of 1st KitID
                        If KitIdArray(0) = 0 Then
                           KitIdArray(0) = kitListID
                           'KitIdArray(0) = kitListID
                        'Takes care of 2nd KitID
                                ElseIf KitIdArray(0) <> kitListID And KitIdArray(1) = 0 Then
                           KitIdArray(1) = kitListID
                        'Takes care of 3rd KitID
                        ElseIf KitIdArray(1) <> kitListID And KitIdArray(2) = 0 Then
                           KitIdArray(2) = kitListID
                        'Takes care of 4th KitID
                        ElseIf KitIdArray(1) <> kitListID And KitIdArray(2) <> kitListID And KitIdArray(3) = 0 Then
                           KitIdArray(3) = kitListID
                        'Takes care of 5th KitID
                        ElseIf KitIdArray(1) <> kitListID And KitIdArray(2) <> kitListID And KitIdArray(3) <> kitListID And KitIdArray(4) = 0 Then
                           KitIdArray(4) = kitListID
                        'Takes care of 6th KitID
                        ElseIf KitIdArray(1) <> kitListID And KitIdArray(2) <> kitListID And KitIdArray(3) <> kitListID And KitIdArray(4) <> kitListID And KitIdArray(5) = 0 Then
                           KitIdArray(5) = kitListID
                        'Takes care of 7th KitID
                        ElseIf KitIdArray(1) <> kitListID And KitIdArray(2) <> kitListID And KitIdArray(3) <> kitListID And KitIdArray(4) <> kitListID And KitIdArray(5) <> kitListID And KitIdArray(6) = 0 Then
                           KitIdArray(6) = kitListID
                        'Takes care of 8th KitID
                        ElseIf KitIdArray(1) <> kitListID And KitIdArray(2) <> kitListID And KitIdArray(3) <> kitListID And KitIdArray(4) <> kitListID And KitIdArray(5) <> kitListID And KitIdArray(6) <> kitListID And KitIdArray(7) = 0 Then
                           KitIdArray(7) = kitListID
                        'Takes care of 9th KitID
                        ElseIf KitIdArray(1) <> kitListID And KitIdArray(2) <> kitListID And KitIdArray(3) <> kitListID And KitIdArray(4) <> kitListID And KitIdArray(5) <> kitListID And KitIdArray(6) <> kitListID And KitIdArray(7) <> kitListID And KitIdArray(8) = 0 Then
                           KitIdArray(8) = kitListID
                        'Takes care of 10th KitID
                        ElseIf KitIdArray(1) <> kitListID And KitIdArray(2) <> kitListID And KitIdArray(3) <> kitListID And KitIdArray(4) <> kitListID And KitIdArray(5) <> kitListID And KitIdArray(6) <> kitListID And KitIdArray(7) <> kitListID And KitIdArray(8) <> kitListID And KitIdArray(9) = 0 Then
                           KitIdArray(9) = kitListID
                        End If
                        PDebug "KitIdArray(0)= " & KitIdArray(0)
                        PDebug "KitIdArray(1)= " & KitIdArray(1)
                        PDebug "KitIdArray(2)= " & KitIdArray(2)
                        PDebug "KitIdArray(3)= " & KitIdArray(3)
                        PDebug "KitIdArray(4)= " & KitIdArray(4)
                        PDebug "KitIdArray(5)= " & KitIdArray(5)
                        PDebug "KitIdArray(6)= " & KitIdArray(6)
                        PDebug "KitIdArray(7)= " & KitIdArray(7)
                        PDebug "KitIdArray(8)= " & KitIdArray(8)
                        PDebug "KitIdArray(9)= " & KitIdArray(9)
                        set rsStockItemBelongToKitES = server.createObject("adodb.recordset")
                        'Now go ahead and get the stock components that make up a kit
                        sqlStockItemBelongToKitES = "SELECT * FROM nStockItemBelongToKitES WHERE ClientID = " & ClientID & _
                        " AND ParentID = " & kitListID
                        pdebug sqlStockItemBelongToKitES
                        rsStockItemBelongToKitES.open sqlStockItemBelongToKitES, dbconn, adUseClient, adLockreadonly, adCmdText
                        'HowManyParentIDCount = 0 ' KitID Counter
                        'HowManyParentIDCount = rsStockItemBelongToKitES.recordcount
                        'do while HowManyParentIDCount > 0
                        rw "<p>"
                        'Add the hyperlink to Add a Stock Component to the kit in question by using the ParentID
                        'if security(sClientAdmin) then
                              'rw "<a href=""javascript:addtokit(" & rsStockItemBelongToKitES("ParentID") & ",'" & EditKitName & "','" &  false & "')"">Add a new component</a><p>"
                        'end if
                        'This is where the KitIdArray is passed into the Javascript function as shown below(KitIdArray(0)):
                        'Add the hyperlink to Add a Stock Component to the kit in question by using the ParentID
                        if security(sClientAdmin) then
                              rw "<a href=""javascript:addtokit2(" & KitIdArray(0) & ",'" & EditKitName & "','" &  false & "')"">Add a new component</a><p>"
                        end if
                  
                        
                        'loop
                        'Add the Titles to each column
                        rw "<table cellspacing=2 cellpadding=2 border=0>"
                        rw "<tr valign=top>"
                        rw "<td class=""bodytext"">&nbsp;</td>"
                        rw "<td class=""tablehead"">Component Code</td>"
                        rw "<td class=""tablehead"">Component Name</td>"
                        rw "<td class=""tablehead"">Qty</td>"
                        rw "<td class=""tablehead"">UnitCost</td>"
                        rw "<td class=""tablehead"">Available</td>"
                        rw "</tr>"
                        kitnum = 0 ' array counter
                        childCount = rsStockItemBelongToKitES.recordcount
                        do while not rsStockItemBelongToKitES.eof
                                                      
                              if CurItemNum mod 2 = 1 then RowStyle = " style=""background-color:#F2F2F2;""" else RowStyle = ""
                                    rw "<tr valign=top" & RowStyle & ">"
                                    rw "<td class=""small"" width=10 style=""background-color:#ffffff;"">"
                                    
                                    if security(sClientAdmin)  then
                                          rw "<a href=""javascript:submitconfirm(" & rsStockItemBelongToKitES("ChildID") & "," & rsStockItemBelongToKitES("ParentID") & "," & childCount & ")""><img align=top src=""../img/trash16.gif"" border=0></a>"
                                    else
                                          rw "*"
                                    end if
                              rw "</td>"
                              rw "<td class=""small"">"
                              if not rsStockItemBelongToKitES("dcode") = " " and security(sSuperUser) then
                                    if security(sClientAdmin) then
                                          rw "<a href=""/inv/edititemES.asp?id=" & rsStockItemBelongToKitES("ChildID") & "&stage=1"">"& rsStockItemBelongToKitES("Code") & "-" & rsStockItemBelongToKitES("Dcode") & "</a>&nbsp;</td>"
                                    else
                                          rw rsStockItemBelongToKitES("Code") & "-" & rsStockItemBelongToKitES("Dcode") & "&nbsp;</td>"
                                    end if
                              else
                                    if security(sClientAdmin) then
                                          rw "<a href=""/inv/edititemES.asp?id=" & rsStockItemBelongToKitES("ChildID") & "&stage=1"">"& rsStockItemBelongToKitES("Code") & "</a>&nbsp;</td>"
                                    else
                                          rw rsStockItemBelongToKitES("Code") & "&nbsp;</td>"
                                    end if
                              end if
                              
                              Available = UnCommittedStock(rsStockItemBelongToKitES("StockID")) 'uncommitted available in stock
                              kitQty = rsStockItemBelongToKitES("qty")
                              rw "<td class=""small"">" & rsStockItemBelongToKitES("StockName") & "&nbsp;</td>"
                              if kitQty > Available then
                                    rw "<td class=""small"" style=""color: red;"" align=""right"">* &nbsp;<a href=""javascript:editkitqty(" & rsStockItemBelongToKitES("ParentID") & ", " & rsStockItemBelongToKitES("StockID") & ", " & KitQty & ", '" & KitName & "');"">" & kitQty & "</a>&nbsp;</td>"
                                    insufficientqty = true
                              else
                                    rw "<td class=""small"" style=""color: green;"" align=""right""><a href=""javascript:editkitqty(" & rsStockItemBelongToKitES("ParentID") & ", " & rsStockItemBelongToKitES("StockID") & ", " & KitQty & ", '" & KitName & "');"">" & kitQty & "</a>&nbsp;</td>"
                              end if
                              rw "<td class=""small"" align=""right"">" & rsStockItemBelongToKitES("UnitCost") & "&nbsp;</td>"
                              rw "<td class=""small"" align=""right"">" & Available & "&nbsp;</td>"
                              maxkits = Available/KitQty
                              kitArray(kitnum) = int(maxkits)
                              pdebug kitArray(kitnum)
                              kitnum = Kitnum + 1
                              rw "</tr>"
                              CurItemNum = CurItemNum + 1
                              kitcost = kitQty * rsStockItemBelongToKitES("unitcost")
                              totalCost = totalCost + kitcost
                               rsStockItemBelongToKitES.movenext
                        loop
                        
                                                
                        if kitArray(0) > 0 then
                              rw "<p class=""bodytext""> Based on the current available stock a total of <span style=""color: green;""> <b>" & kitArray(0)  & "</b> </span> kits can be created."
                        else
                              rw "<p class=""bodytext"" style=""color: red;"" > At this time there is insufficient stock to create a kit."
                        end if
                        rw "<tr valign=top>"
                              rw "<td class=""bodytext"" align=right>&nbsp;</td>"
                              rw "<td class=""bodytext"" align=right>&nbsp;</td>"
                              rw "<td class=""bodytext"" colspan=2><b>Total Kit Cost</b></td>"
                              rw "<td class=""bodytext"" align=right>" & fnum(totalCost,2) & "</td>"
                        rw "</tr>"

                        rsnkitSummary.movenext
                        
                  loop
                        if not insufficientqty then
                              aSorted = fnSort(kitarray, 1)
                              firstelement = false
                              for index = lbound(aSorted) to ubound(aSorted)
                                    pdebug aSorted(index) & " "
                                    if not firstelement then
                                          if aSorted(index) > 0 then
                                                pdebug "lowest number" &  aSorted(index)
                                                firstelement = true
                                                kitArray(0) = asorted(index)
                                          end if
                                    end if
                              next

                        else
                              kitArray(0) = 0
                        end if
                        'rw "<tr valign=top>"
                              'rw "<td class=""bodytext"" align=right>&nbsp;</td>"
                              'rw "<td class=""bodytext"" align=right>&nbsp;</td>"
                              'rw "<td class=""bodytext"" colspan=2><b>Total Kit Cost</b></td>"
                              'rw "<td class=""bodytext"" align=right>" & fnum(totalCost,2) & "</td>"
                        'rw "</tr>"
                        
                  rw "</table>"
                  
                  rsStockItemBelongToKitES.close
                  rsnkitSummary.close

                  'rw "<p><a href=""kitssummaryES.asp"">&nbsp;Back</a>"
            end if
      end if
      dbconn.close
      set dbconn = nothing
end if
%>

<!--#include file="../inc/postproc.asp" -->

<!-- end main content -->
                        </td>
                  </tr>
            </table>
                  <!--#include file="../inc/commonmenuscriptsfooter.asp" -->

      </body>
</html>

The asp page that the values of array is passed into (addkitproductES.asp):
<!--#include file="../inc/adovbs.asp" -->
<!--#include file="../inc/std.asp" -->
<!--#include file="../inc/const.asp" -->

<!--#include file="../inc/securitycheck.asp" -->

<html>
      <head>
      <title>

      </title>
      <link rel=stylesheet type="text/css" href="/inc/style.css">
      </head>
      <body class="bodytext">

<!-- main page content -->

<script language="JavaScript">
<!-- Hide

var ACProdArrAcc = new Array()

function ProdAcc(IDAcc, PNameAcc) {
      this.IDAcc            = IDAcc
      this.PNameAcc      = PNameAcc
}

<%
            stockID = request("stockID")
            set dbconn = Server.CreateObject("ADODB.Connection")
            dbconn.open ODBCsource
            set rsStockSub = Server.CreateObject("ADODB.Recordset")
            StockSQL = "SELECT Stock.StockID, Stock.Code, Stock.Dcode, Stock.StockName " & _
                  "FROM Clients INNER JOIN Stock ON Clients.ClientID = Stock.ClientID " & _
                  "WHERE (((Clients.ClientID)=" & ClientID & ") AND ((Stock.Deleted) Is Null)) " & _
                  "ORDER BY StockName"
            rsStockSub.Open StockSQL, dbconn, adOpenKeyset, AdLockReadOnly, adCmdText
            if rsStockSub.eof then            ' oops
                  PError "An internal error occured."
            else
                  while not rsStockSub.eof
                  if security(sSuperUser) then
                        SafeStockName = replace(rsStockSub("StockName") & "-" & rsStockSub("Dcode"), "'", "\'")
                  else
                        SafeStockName = replace(rsStockSub("StockName"), "'", "\'")
                  end if
%>
                        ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(<% = rsStockSub("StockID") %>,'<% = SafeStockName %>');
<%
                        rsStockSub.movenext
                  wend
            end if
%>



      var ResultsAcc;
      var HTMLAcc;
      function FindProductAcc(zoneAcc, event) {

            ResultsAcc = 0;
            HTMLAcc      = "";

            resultDivAcc = document.getElementById('resultAcc');
            resultTitleDivAcc = document.getElementById('resultTitleAcc');
            resultMessageDivAcc = document.getElementById('resultMessageAcc');
            resultListDivAcc = document.getElementById('resultListAcc');
            ACBAcc = document.searchAcc_form.searchAcc.value;

            for (i=0; i< ACProdArrAcc.length; i++) {
                  if(ACBAcc.length > 0){
                        var PName = ACProdArrAcc[i].PNameAcc.replace(/'/g, "\"'\"");

                        if (PName.toLowerCase().substr(0, ACBAcc.length) == ACBAcc.toLowerCase() || PName.toLowerCase().indexOf(ACBAcc.toLowerCase()) > -1) {
                              HTMLAcc = HTMLAcc + "<a href='javascript:ReturnSub(" + <% = stockID %> + ", " + ACProdArrAcc[i].IDAcc + ")' class='link'>" + PName + "</a><br>"
                              ResultsAcc += 1;
                        }
                  }
            }

            if (ResultsAcc == 0){
                  resultDivAcc.style.display = 'block';
                  if (ACBAcc.length > 0) {
                        resultMessageDivAcc.style.display = 'block';
                  } else {
                        resultMessageDivAcc.style.display = 'none';
                  }
                  resultTitleDivAcc.style.display = 'none';
                  resultListDivAcc.style.display = 'none';
                  resultListDivAcc.innerHTML = "";
                  resultNum.style.display = 'none';
            }
            else{
                  resultDivAcc.style.display = 'block';
                  resultMessageDivAcc.style.display = 'none';
                  resultTitleDivAcc.style.display = 'block';
                  resultListDivAcc.style.display = 'block';
                  resultListDivAcc.innerHTML = HTMLAcc;
                  resultNum.style.display = 'block';
                  resultNum.innerHTML = ResultsAcc + ' products found.<p>';
            }
      }

      function submitAccFinder() {
            if (ResultsAcc >= 1) {
                  var index = HTMLAcc.indexOf("'");
                  strLocation = HTMLAcc.substr(index+1, HTMLAcc.indexOf("'", index+1)-(index+1));
                  document.location.href = strLocation;
            }
            return false;
      }

      function ReturnSub(stockID, ChildID) {
            var regexp = /^(\d+)$/;

            if (regexp.test(document.searchAcc_form.newqty.value)) {
                  if (document.searchAcc_form.newqty.value < 1) {

                        window.alert("Product's quantity must be atleast 1");
                           }

                  else {

                        window.opener.location='addkitdetailES.asp?parentID=' + stockID + '&newchildid=' + ChildID + '&newqty=' + document.searchAcc_form.newqty.value + '&newkit=' + '<% = request("newflag") %>' + '&name=' + '<% = request("name") %>';
                        window.opener.focus();
                        self.close();
                       }
            }
             else {
            window.alert("Quantity is either null or not a number");
      }

      }
-->
</script>

            <center><span class="bodyhead">Add a new component to <% = request("name") %></span><p>
<%


      stockID = request("stockID")
      Pdebug stockID



rw "<FORM id=searchAcc_form style=""MARGIN-BOTTOM: 0px"" " & _
      "name=searchAcc_form onsubmit=return(submitAccFinder()); " & _
      "action="""" method=get>"
   rw "<table border=0 cellspacing=0 cellpadding=2 width=""95%"">"
      rw "<tr>"
      rw "<TD vAlign=top width=100 class=""bodytext"">Enter Quantity: " & _
      "<input name=newqty size=5 style=""text-align:center;font-weight:bold;font-size:14px""></td><p>"



rw "<TD vAlign=top width=100 class=""bodytext"">"
      rw "<b>Product Name</b><br>"
      rw "<INPUT id=searchAcc onkeyup='FindProductAcc(""pp"", event)' " & _
            "style=""BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; " & _
            "BORDER-LEFT: black 1px solid; BORDER-BOTTOM: black 1px solid"" name=searchAcc>&nbsp;&nbsp;<p>"
            rw "<DIV id=resultNum style=""DISPLAY: none""></DIV>"
            rw "<a href=""javascript:window.close();"">Cancel</a>"
            rw "</TD>"

      rw "<td class=""bodytext"">"

      rw "<DIV id=resultAcc style=""DISPLAY: none"">"
      rw "<TABLE cellSpacing=0 cellPadding=0 border=0>"
      rw "<TR>"
      rw "<TD vAlign=top class=""bodytext"">"
      rw "<DIV id=resultTitleAcc "
      rw "style=""DISPLAY: none""><b>Matching products (Name)</b></DIV>"
      rw "<DIV id=resultListAcc "
      rw "style=""DISPLAY: none""></DIV>"
      rw "<DIV id=resultMessageAcc "
      rw "style=""DISPLAY: none"">Sorry, no matching products found.</DIV>"

        rw "</td></tr>"
      rw "</table>"
        rw "</td></tr>"
      rw "</table><p>"
      rw "</form>"
%>

<!-- end main content -->
      </center></body>
</html>


darrylf290567Asked:
Who is Participating?
 
thecodistConnect With a Mentor Commented:
Yes, Thank you!

Sincerely,
TheCodist

0
 
Michel PlungjanIT ExpertCommented:
Not seeing this actually run, I do see a major syntax error.

newWin = open(openURL, 'mydoc', myFeatures);
newWin.focus();
newWin.document.close(); <<<<<<<<<<<< REMOVE THIS

the newWin.document.close is used after a newWin.document.write

NOT a window.open
0
 
Michel PlungjanIT ExpertCommented:
Secondly I would change

"<a href=""javascript:addtokit2(" & KitIdArray(0) & ",'" & EditKitName & "','" &  false & "')"">Add a new component</a><p>
to

"<a href=""#"" onClick="addtokit2(" & KitIdArray(0) & ",'" & EditKitName & "','" &  false & "'); return false"">Add a new component</a><p>

Ditto here:

<a href=""javascript:submitconfirm(" & rsStockItemBelongToKitES("ChildID") & "," & rsStockItemBelongToKitES("ParentID") & "," & childCount & ")""><img align=top src=""../img/trash16.gif"" border=0></a>

really should be

<a href=""#"" onClick=submitconfirm(" & rsStockItemBelongToKitES("ChildID") & "," & rsStockItemBelongToKitES("ParentID") & "," & childCount & "); return false""><img align=top src=""../img/trash16.gif"" border=0></a>

to stop the links themselves from being followed
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
darrylf290567Author Commented:
Hi mplungian,

I need to know how to pass the array of StocklistID values into the addkit2 function without any errors because I am getting a Type Mismatch error. Can you help with that issue because that is the major one that I am talking about.

Kind Regards
darrylf290567
0
 
Michel PlungjanIT ExpertCommented:
What is a stockID - string or number?

I would expect single quotes here:

addtokit('" & StockID & "',

which is a MUST if it is a string

So your ASP gives type mismatch?

If it expects a number and gets a string or vice versa you need to convert it:


stockID = request("stockID").ToString()

Have a look here

http://forums.asp.net/t/105614.aspx
0
 
darrylf290567Author Commented:
a stockid is a number but i am talking about passing an array into the function that calls another page. Can you please show me some code as to how to do it.
This is where I set assign values to each array index:
 kitListID = rsnkitSummary("ParentID")
                        PDebug "kitID= " & kitListID
                        'Takes care of 1st KitID
                        If KitIdArray(0) = 0 Then
                           KitIdArray(0) = kitListID
                           'KitIdArray(0) = kitListID
                        'Takes care of 2nd KitID
                                ElseIf KitIdArray(0) <> kitListID And KitIdArray(1) = 0 Then
                           KitIdArray(1) = kitListID
                        'Takes care of 3rd KitID
                        ElseIf KitIdArray(1) <> kitListID And KitIdArray(2) = 0 Then
                           KitIdArray(2) = kitListID
                        'Takes care of 4th KitID
                        ElseIf KitIdArray(1) <> kitListID And KitIdArray(2) <> kitListID And KitIdArray(3) = 0 Then
                           KitIdArray(3) = kitListID
                        'Takes care of 5th KitID
                        ElseIf KitIdArray(1) <> kitListID And KitIdArray(2) <> kitListID And KitIdArray(3) <> kitListID And KitIdArray(4) = 0 Then
                           KitIdArray(4) = kitListID
                        'Takes care of 6th KitID
                        ElseIf KitIdArray(1) <> kitListID And KitIdArray(2) <> kitListID And KitIdArray(3) <> kitListID And KitIdArray(4) <> kitListID And KitIdArray(5) = 0 Then
                           KitIdArray(5) = kitListID
                        'Takes care of 7th KitID
                        ElseIf KitIdArray(1) <> kitListID And KitIdArray(2) <> kitListID And KitIdArray(3) <> kitListID And KitIdArray(4) <> kitListID And KitIdArray(5) <> kitListID And KitIdArray(6) = 0 Then
                           KitIdArray(6) = kitListID
                        'Takes care of 8th KitID
                        ElseIf KitIdArray(1) <> kitListID And KitIdArray(2) <> kitListID And KitIdArray(3) <> kitListID And KitIdArray(4) <> kitListID And KitIdArray(5) <> kitListID And KitIdArray(6) <> kitListID And KitIdArray(7) = 0 Then
                           KitIdArray(7) = kitListID
                        'Takes care of 9th KitID
                        ElseIf KitIdArray(1) <> kitListID And KitIdArray(2) <> kitListID And KitIdArray(3) <> kitListID And KitIdArray(4) <> kitListID And KitIdArray(5) <> kitListID And KitIdArray(6) <> kitListID And KitIdArray(7) <> kitListID And KitIdArray(8) = 0 Then
                           KitIdArray(8) = kitListID
                        'Takes care of 10th KitID
                        ElseIf KitIdArray(1) <> kitListID And KitIdArray(2) <> kitListID And KitIdArray(3) <> kitListID And KitIdArray(4) <> kitListID And KitIdArray(5) <> kitListID And KitIdArray(6) <> kitListID And KitIdArray(7) <> kitListID And KitIdArray(8) <> kitListID And KitIdArray(9) = 0 Then
                           KitIdArray(9) = kitListID
                        End If

Then I want to know how to call the function:

This how I do it BUT I want to pass in all the array subscripts that have a vlaue: eg KitIdArray(0) , KitIdArray(2) and so on....
If you look at my code below I only pass in KitIdArray(0). I really want to just pass in the ENTIRE KitIdArray like this: KitIdArray and in the other asp page I can then handle all the values in the KitIdArray.
if security(sClientAdmin) then
                              rw "<a href=""javascript:addtokit2(" & KitIdArray(0) & ",'" & EditKitName & "','" &  false & "')"">Add a new component</a><p>"
                        end if

This the function below that is being called:
'Array of StockListIds(KitIdArray) that are passed into this javascript function below:
function addtokit2(KitIdArray, kitname, newFlag) {
      var myBars = 'directories=no,location=no,menubar=no,status=no,';
      myBars += 'titlebar=no,toolbar=no';
      var myOptions = 'scrollbars=yes,width=650,height=500,resizeable=no';
      var myFeatures = myBars + ',' + myOptions;
      var openURL = 'addkitproductES.asp?'
      openURL += 'stockid=' + KitIdArray + '&name=' + kitname + '&newflag=' + newFlag
      newWin = open(openURL, 'mydoc', myFeatures);
      newWin.focus();
      newWin.document.close();
which in turn calls addkitproductES.asp an passes the KitIdArray as part of the query string.

When I pass in the KitIdArray as a whole array to the function above I get a Type Mismatch.

kind regards
darrylf290567
0
 
Michel PlungjanIT ExpertCommented:
Because string concatenation works on strings, not on arrays and javascript will not understand an asp array

You need to flatten it when you send it to the js and split the result from js in the asp...

0
 
thecodistCommented:
First of all, it looks like you are passing a single value from your KitIdArray array into your function, not the whole array (addtokit2(" & KitIdArray(0) & "). Is this correct?

Second, I noticed that your If, ElseIf block that loads your KitIdArray array does not contain an Else statement and you do not load a default value into KitIdArray(0). Do you think you have an unhandled ELSE condition where your array does not contain a value at all? You might see if you can check the value you are about to pass into the function just prior to calling the function maybe with an ALERT statement to see if it actually contains a value?
<a href=""javascript:alert(" & KitIdArray(0) & "); addtokit2(" & KitIdArray(0) & ",'" & EditKitName & "','" &  false & "')"">Add a new component</a><p>"
You could also check to see if the value is a number:
<a href=""javascript:alert(isNaN(" & KitIdArray(0) & ")); addtokit2(" & KitIdArray(0) & ",'" & EditKitName & "','" &  false & "')"">Add a new component</a><p>"
0
 
darrylf290567Author Commented:
Hi thecodist,

Yes I am passing in only ONE value BUT as I mentioned before I need to pass the whole array. Can you show me how to do this?

Hi mplungian,

How do you do it then. Can you show me the code of how to do it?

kindest regards
darrylf290567
0
 
thecodistCommented:
You should be able to use the Join function to concatenate on the fly into a comma-delimited list the values in your array. This way you can pass the contents of the whole array at one time.

In ASP I believe the syntax is just 'Join(KitIdArray)'. I can't remember but you may be allowed to specify the delimiter as the second parameter 'Join(KitIdArray, ",")'. I know the second version is the correct syntax for VB.NET as long as the array is defined as either STRING or OBJECT.
0
 
darrylf290567Author Commented:
Hi All,

I want to know how to pass the array as I mentioned earlier on to another page through a javascript function with all the values in the array. It is that question that I am asking no other question.

Can you guys help or not that is all?

kind regards
darrylf290567
0
 
darrylf290567Author Commented:
Hi All,

I have been able to resolve the problem myself. None of the comments above have helped me with the solution. I have had to rewrite the code in its entirety myself.

Thank you everyone anyway for trying to help me.

kind regards
darrylf290567
0
 
darrylf290567Author Commented:
Hi All,

Forget the abovementioned comment of my own. It did not work. I thought it did but it did not work.

I want to pass a vbscript array into a javascript function:

Here is the line of code that calls the javascript function:
'Add the hyperlink to Add a Stock Component to the kit in question by using the ParentID
                        if security(sClientAdmin) then
                              rw "<a href=""javascript:addtokit2(" & KitIdArray(0) & ",'" & EditKitName & "','" &  false & "')"">Add a new component</a><p>"
                        end if

here is the function:

'Array of StockListIds(KitIdArray) that are passed into this javascript function below:
function addtokit2(KitIdArray, kitname, newFlag) {
      var myBars = 'directories=no,location=no,menubar=no,status=no,';
      myBars += 'titlebar=no,toolbar=no';
      var myOptions = 'scrollbars=yes,width=650,height=500,resizeable=no';
      var myFeatures = myBars + ',' + myOptions;
      var openURL = 'addkitproductES.asp?'
      openURL += 'stockid=' + KitIdArray + '&name=' + kitname + '&newflag=' + newFlag
      newWin = open(openURL, 'mydoc', myFeatures);
      newWin.focus();
      newWin.document.close();
}

I need to pass all the values not just array(0) but all the values.
0
 
thecodistCommented:
I don't know why the join method I provided did not work for you. I went through your code. This should work to pass in a comma delimited list of array values into your Javascript function:

addtokit2('" & Join(KitIdArray, ",") & "','"

Did you try this? Your ASP code can then take this value and split it back into a VB array if you want using the Split function. Please double-check my suggestion. I have done this myself many times.
0
 
darrylf290567Author Commented:
Hi mplungian,

I am not using asp.net but classic asp. The article you sent me is concerned with asp.net. Could you please provide me with classic asp.

Hi thecodist,

I will try your code today sometime and get back to you.

kind regards
darrylf290567
0
 
Michel PlungjanIT ExpertCommented:
Darryl, the articles may be .net but the principle is the same

1. flatten the array to a string
2. pass the string to the javascript
3. pass the string to the asp
4. split the string in the asp to get the array
0
 
darrylf290567Author Commented:
Hi thecodist,

I tried your code and what is being passed is as follows:
19593,19594,19595,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
The first 3 values are correct but all the commas are not how do I only check and pass what is a value in the array?

Please help.
kindest regards
darrylf290567

0
 
darrylf290567Author Commented:
Hi thecodist,

as part of my previous comment:
KitIdArray(0) = 19593
KitIdArray(1) = 19594
KitIdArray(2) = 19595
the rest of the KitIdArray is nulls

kind regards
darrylf290567
0
 
Michel PlungjanIT ExpertCommented:
0
 
thecodistCommented:
Well you could wrap the Join in a Replace to remove extra commas like this:

addtokit2('" & Replace(Join(KitIdArray, ","),",,","") & "','"

Or if there is a space between the commas use this:

addtokit2('" & Replace(Join(KitIdArray, ","),", ,","") & "','"
0
 
darrylf290567Author Commented:
Hi thecodist,

Would I only use your code below if there was nulls in the other indexes of the array? How could I check for nulls or if there was no value in the rest of the array?
Well you could wrap the Join in a Replace to remove extra commas like this:

addtokit2('" & Replace(Join(KitIdArray, ","),",,","") & "','"

Or if there is a space between the commas use this:

addtokit2('" & Replace(Join(KitIdArray, ","),", ,","") & "','"

kindest regards
darrylf290567
0
 
darrylf290567Author Commented:
Hi thecodist,
Your code:
addtokit2('" & Replace(Join(KitIdArray, ","),",,","") & "','"
worked. However, for an extra 100 points because this whole question relates to the same problem I am passing the values (19593,19594,19595) to the javascript function on the same page as shown in the attached code snippet. This javascript function then calls another page: addkitproductES.asp. I need to know how to unravel the KitIdArray and pass these values into a loop to obtain the stock items to add to each kit. I will send you document that shows a screenshot of how it works and displayed.

I will also send you addkitproductES.asp where you type in the quantity and the stock name that you want to add to the kit.

The code for that asp page is in the code snippet under the javascript function.

In the screenshot as you type in the a value in the Product Name box then stock items will appear on the right hand side of the Product Name box, corresponding to the value of 19353 being passed in. However, now we have 3 values passed in and the code does not know how to handle it. Maybe you can shed some light to help me please? I really appreciate it.

kindest regards
darrylf290567




function addtokit2(KitIdArray, kitname, newFlag) {
	var myBars = 'directories=no,location=no,menubar=no,status=no,';
	myBars += 'titlebar=no,toolbar=no';
	var myOptions = 'scrollbars=yes,width=650,height=500,resizeable=no';
	var myFeatures = myBars + ',' + myOptions;
	var openURL = 'addkitproductES.asp?'
	openURL += 'stockid=' + KitIdArray + '&name=' + kitname + '&newflag=' + newFlag
	newWin = open(openURL, 'mydoc', myFeatures);
	newWin.focus();
	newWin.document.close();
 
addkitproductES.asp code:
<!--#include file="../inc/adovbs.asp" -->
<!--#include file="../inc/std.asp" -->
<!--#include file="../inc/const.asp" -->
 
<!--#include file="../inc/securitycheck.asp" -->
 
<html>
	<head>
	<title>
 
	</title>
	<link rel=stylesheet type="text/css" href="/inc/style.css">
	</head>
	<body class="bodytext">
 
<!-- main page content -->
 
<script language="JavaScript">
<!-- Hide
 
var ACProdArrAcc = new Array()
 
function ProdAcc(IDAcc, PNameAcc) {
	this.IDAcc		= IDAcc
	this.PNameAcc	= PNameAcc
}
 
<%
		stockID = request("stockID")
		set dbconn = Server.CreateObject("ADODB.Connection")
		dbconn.open ODBCsource
		set rsStockSub = Server.CreateObject("ADODB.Recordset")
		StockSQL = "SELECT Stock.StockID, Stock.Code, Stock.Dcode, Stock.StockName " & _
			"FROM Clients INNER JOIN Stock ON Clients.ClientID = Stock.ClientID " & _
			"WHERE (((Clients.ClientID)=" & ClientID & ") AND ((Stock.Deleted) Is Null)) " & _
			"ORDER BY StockName"
		
		Pdebug StockSQL
		rsStockSub.Open StockSQL, dbconn, adOpenKeyset, AdLockReadOnly, adCmdText
		if rsStockSub.eof then		' oops
			PError "An internal error occured."
		else
			while not rsStockSub.eof
			if security(sSuperUser) then
				SafeStockName = replace(rsStockSub("StockName") & "-" & rsStockSub("Dcode"), "'", "\'")
			else
				SafeStockName = replace(rsStockSub("StockName"), "'", "\'")
			end if
%>
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(<% = rsStockSub("StockID") %>,'<% = SafeStockName %>');
<%
				rsStockSub.movenext
			wend
		end if
%>
 
 
 
	var ResultsAcc;
	var HTMLAcc;
	function FindProductAcc(zoneAcc, event) {
 
		ResultsAcc = 0;
		HTMLAcc	= "";
 
		resultDivAcc = document.getElementById('resultAcc');
		resultTitleDivAcc = document.getElementById('resultTitleAcc');
		resultMessageDivAcc = document.getElementById('resultMessageAcc');
		resultListDivAcc = document.getElementById('resultListAcc');
		ACBAcc = document.searchAcc_form.searchAcc.value;
 
		for (i=0; i< ACProdArrAcc.length; i++) {
			if(ACBAcc.length > 0){
				var PName = ACProdArrAcc[i].PNameAcc.replace(/'/g, "\"'\"");
 
				if (PName.toLowerCase().substr(0, ACBAcc.length) == ACBAcc.toLowerCase() || PName.toLowerCase().indexOf(ACBAcc.toLowerCase()) > -1) {
					HTMLAcc = HTMLAcc + "<a href='javascript:ReturnSub(" + <% = stockID %> + ", " + ACProdArrAcc[i].IDAcc + ")' class='link'>" + PName + "</a><br>"
					ResultsAcc += 1;
				}
			}
		}
 
		if (ResultsAcc == 0){
			resultDivAcc.style.display = 'block';
			if (ACBAcc.length > 0) {
				resultMessageDivAcc.style.display = 'block';
			} else {
				resultMessageDivAcc.style.display = 'none';
			}
			resultTitleDivAcc.style.display = 'none';
			resultListDivAcc.style.display = 'none';
			resultListDivAcc.innerHTML = "";
			resultNum.style.display = 'none';
		}
		else{
			resultDivAcc.style.display = 'block';
			resultMessageDivAcc.style.display = 'none';
			resultTitleDivAcc.style.display = 'block';
			resultListDivAcc.style.display = 'block';
			resultListDivAcc.innerHTML = HTMLAcc;
			resultNum.style.display = 'block';
			resultNum.innerHTML = ResultsAcc + ' products found.<p>';
		}
	}
 
	function submitAccFinder() {
		if (ResultsAcc >= 1) {
			var index = HTMLAcc.indexOf("'");
			strLocation = HTMLAcc.substr(index+1, HTMLAcc.indexOf("'", index+1)-(index+1));
			document.location.href = strLocation;
		}
		return false;
	}
 
	function ReturnSub(stockID, ChildID) {
		var regexp = /^(\d+)$/;
 
		if (regexp.test(document.searchAcc_form.newqty.value)) {
			if (document.searchAcc_form.newqty.value < 1) {
 
				window.alert("Product's quantity must be atleast 1");
		         	}
 
			else {
 
				window.opener.location='addkitdetailES.asp?parentID=' + stockID + '&newchildid=' + ChildID + '&newqty=' + document.searchAcc_form.newqty.value + '&newkit=' + '<% = request("newflag") %>' + '&name=' + '<% = request("name") %>';
				window.opener.focus();
				self.close();
			     }
		}
		 else {
		window.alert("Quantity is either null or not a number");
	}
 
	}
-->
</script>
 
		<center><span class="bodyhead">Add a new component to <% = request("name") %></span><p>
<%
 
 
	stockID = request("stockID")
	Pdebug stockID
 
 
 
rw "<FORM id=searchAcc_form style=""MARGIN-BOTTOM: 0px"" " & _
	"name=searchAcc_form onsubmit=return(submitAccFinder()); " & _
	"action="""" method=get>"
   rw "<table border=0 cellspacing=0 cellpadding=2 width=""95%"">"
	rw "<tr>"
	rw "<TD vAlign=top width=100 class=""bodytext"">Enter Quantity: " & _
	"<input name=newqty size=5 style=""text-align:center;font-weight:bold;font-size:14px""></td><p>"
 
 
 
rw "<TD vAlign=top width=100 class=""bodytext"">"
	rw "<b>Product Name</b><br>"
	rw "<INPUT id=searchAcc onkeyup='FindProductAcc(""pp"", event)' " & _
		"style=""BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; " & _
		"BORDER-LEFT: black 1px solid; BORDER-BOTTOM: black 1px solid"" name=searchAcc>&nbsp;&nbsp;<p>"
		rw "<DIV id=resultNum style=""DISPLAY: none""></DIV>"
		rw "<a href=""javascript:window.close();"">Cancel</a>"
		rw "</TD>"
 
	rw "<td class=""bodytext"">"
 
	rw "<DIV id=resultAcc style=""DISPLAY: none"">"
	rw "<TABLE cellSpacing=0 cellPadding=0 border=0>"
	rw "<TR>"
	rw "<TD vAlign=top class=""bodytext"">"
	rw "<DIV id=resultTitleAcc "
	rw "style=""DISPLAY: none""><b>Matching products (Name)</b></DIV>"
	rw "<DIV id=resultListAcc "
	rw "style=""DISPLAY: none""></DIV>"
	rw "<DIV id=resultMessageAcc "
	rw "style=""DISPLAY: none"">Sorry, no matching products found.</DIV>"
 
	  rw "</td></tr>"
	rw "</table>"
	  rw "</td></tr>"
	rw "</table><p>"
	rw "</form>"
%>
 
<!-- end main content -->
	</center></body>
</html>

Open in new window

addkitproductES.GIF
0
 
darrylf290567Author Commented:
Hi thecodist,

This is the client rendered page before the cahnge of passing in the array to the page via the javascript function: See the code snippet for the html rendered page.

I hope this helps in understanding the problem and the code in the addkitproductES page.

kindest regards
darrylf290567

 
<script type="text/javascript" language="JavaScript">
<!-- Hide
/*
function displayRenderTime()
{
	var renderStopTime;
	var theDate2;
	theDate2= new Date();
 
	renderStopTime = theDate2.getTime();
 
	document.write("<br>renderStopTime=" + renderStopTime + ", renderStartTime=" + renderStartTime);
	document.write("<br>The rendering time was " + ((renderStopTime - renderStartTime) / 1000) + " seconds.");
}
 
function logRenderTime()
{
	
		document.write("<iframe src='/inc/logClientTime.asp?time=" + ((renderStopTime - renderStartTime) / 1000) + "'  height=0 width=0>");
	
 
	document.write("</iframe>");
}
*/
// -->
</script>
 
<span class="debug">strAlertDate=</span><br>
<span class="debug">cookie=<br></span><br>
<span class="debug">strAlertDate=<br></span><br>
 
 
<script type="text/javascript" language="JavaScript">
<!-- Hide
// for the rendering Time logger
var renderStartTime;
var theDate;
	theDate =  new Date();
	renderStartTime = theDate.getTime();
 
 
 
// -->
</script>
 
<span class="debug">gettimeForSecurity() 13/2/2008 19:56:38 EST       </span><br>
<span class="debug">session timeout13/2/2008 19:56:35 EST       </span><br>
<span class="debug">gettimeforsecurity - session timeout =0</span><br>
<span class="debug">re setting session timeout to current time</span><br>
 
 
<html>
	<head>
	<title>
 
	</title>
	<link rel=stylesheet type="text/css" href="/inc/style.css">
	</head>
	<body class="bodytext">
 
<!-- main page content -->
 
<script language="JavaScript">
<!-- Hide
 
var ACProdArrAcc = new Array()
 
function ProdAcc(IDAcc, PNameAcc) {
	this.IDAcc		= IDAcc
	this.PNameAcc	= PNameAcc
}
 
 
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(19614,'EQUIPTEST ITEM- ');
 
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(19583,'ITEM1- ');
 
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(19584,'ITEM1B- ');
 
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(19585,'ITEM1C- ');
 
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(19586,'ITEM2A- ');
 
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(19587,'ITEM2B- ');
 
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(19588,'ITEM2C- ');
 
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(19589,'ITEM3A- ');
 
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(19590,'ITEM3B- ');
 
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(19591,'ITEM3C- ');
 
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(19592,'KIT1- ');
 
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(19593,'KIT1- ');
 
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(19594,'KIT2- ');
 
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(19595,'KIT3- ');
 
 
 
 
	var ResultsAcc;
	var HTMLAcc;
	function FindProductAcc(zoneAcc, event) {
 
		ResultsAcc = 0;
		HTMLAcc	= "";
 
		resultDivAcc = document.getElementById('resultAcc');
		resultTitleDivAcc = document.getElementById('resultTitleAcc');
		resultMessageDivAcc = document.getElementById('resultMessageAcc');
		resultListDivAcc = document.getElementById('resultListAcc');
		ACBAcc = document.searchAcc_form.searchAcc.value;
 
		for (i=0; i< ACProdArrAcc.length; i++) {
			if(ACBAcc.length > 0){
				var PName = ACProdArrAcc[i].PNameAcc.replace(/'/g, "\"'\"");
 
				if (PName.toLowerCase().substr(0, ACBAcc.length) == ACBAcc.toLowerCase() || PName.toLowerCase().indexOf(ACBAcc.toLowerCase()) > -1) {
					HTMLAcc = HTMLAcc + "<a href='javascript:ReturnSub(" + 19593 + ", " + ACProdArrAcc[i].IDAcc + ")' class='link'>" + PName + "</a><br>"
					ResultsAcc += 1;
				}
			}
		}
 
		if (ResultsAcc == 0){
			resultDivAcc.style.display = 'block';
			if (ACBAcc.length > 0) {
				resultMessageDivAcc.style.display = 'block';
			} else {
				resultMessageDivAcc.style.display = 'none';
			}
			resultTitleDivAcc.style.display = 'none';
			resultListDivAcc.style.display = 'none';
			resultListDivAcc.innerHTML = "";
			resultNum.style.display = 'none';
		}
		else{
			resultDivAcc.style.display = 'block';
			resultMessageDivAcc.style.display = 'none';
			resultTitleDivAcc.style.display = 'block';
			resultListDivAcc.style.display = 'block';
			resultListDivAcc.innerHTML = HTMLAcc;
			resultNum.style.display = 'block';
			resultNum.innerHTML = ResultsAcc + ' products found.<p>';
		}
	}
 
	function submitAccFinder() {
		if (ResultsAcc >= 1) {
			var index = HTMLAcc.indexOf("'");
			strLocation = HTMLAcc.substr(index+1, HTMLAcc.indexOf("'", index+1)-(index+1));
			document.location.href = strLocation;
		}
		return false;
	}
 
	function ReturnSub(stockID, ChildID) {
		var regexp = /^(\d+)$/;
 
		if (regexp.test(document.searchAcc_form.newqty.value)) {
			if (document.searchAcc_form.newqty.value < 1) {
 
				window.alert("Product's quantity must be atleast 1");
		         	}
 
			else {
 
				window.opener.location='addkitdetailES.asp?parentID=' + stockID + '&newchildid=' + ChildID + '&newqty=' + document.searchAcc_form.newqty.value + '&newkit=' + 'False' + '&name=' + 'KIT1';
				window.opener.focus();
				self.close();
			     }
		}
		 else {
		window.alert("Quantity is either null or not a number");
	}
 
	}
-->
</script>
 
		<center><span class="bodyhead">Add a new component to KIT1</span><p>
<span class="debug">19593</span><br>
<FORM id=searchAcc_form style="MARGIN-BOTTOM: 0px" name=searchAcc_form onsubmit=return(submitAccFinder()); action="" method=get>
<table border=0 cellspacing=0 cellpadding=2 width="95%">
<tr>
<TD vAlign=top width=100 class="bodytext">Enter Quantity: <input name=newqty size=5 style="text-align:center;font-weight:bold;font-size:14px"></td><p>
<TD vAlign=top width=100 class="bodytext">
<b>Product Name</b><br>
<INPUT id=searchAcc onkeyup='FindProductAcc("pp", event)' style="BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; BORDER-LEFT: black 1px solid; BORDER-BOTTOM: black 1px solid" name=searchAcc>&nbsp;&nbsp;<p>
<DIV id=resultNum style="DISPLAY: none"></DIV>
<a href="javascript:window.close();">Cancel</a>
</TD>
<td class="bodytext">
<DIV id=resultAcc style="DISPLAY: none">
<TABLE cellSpacing=0 cellPadding=0 border=0>
<TR>
<TD vAlign=top class="bodytext">
<DIV id=resultTitleAcc 
style="DISPLAY: none"><b>Matching products (Name)</b></DIV>
<DIV id=resultListAcc 
style="DISPLAY: none"></DIV>
<DIV id=resultMessageAcc 
style="DISPLAY: none">Sorry, no matching products found.</DIV>
</td></tr>
</table>
</td></tr>
</table><p>
</form>
 
 
<!-- end main content -->
	</center></body>
</html>

Open in new window

0
 
thecodistCommented:
Thank you. I do have to attend some meetings this morning. I may not have time to look at this till this afternoon. I'll take a look at it as soon as I can.

0
 
thecodistCommented:
I have looked at the code, however I can't see anywhere that shows the list of items 19593,19594,19595 so I don't know where the problem is occurring. Can you show me the version of the problem page where these values are loaded?
0
 
darrylf290567Author Commented:
Hi thecodist,

I will have to attach the problem page when the HTML is rendered to the client a bit later on as I cannot do it from the office. But basically the three values are being passed in with the URL to the other page.
The HTML I had shown you is how the page was working before I was using arrays and passing only one value. BUT now I have to use an array for a requirement where I need to pass multiple values to the other page via the javascript funtion so th user can add the same stock item to multiple kit ids which are stored in the array.

Kind Regards
darrylf290567
0
 
darrylf290567Author Commented:
Hi thecodist,

I have now attached viewkitdetailES.asp page this is the page that calls the other page in the above comment with the array change implemented.
The callee page is: addKitproductES.asp.
I will attach both pages respectively as they are rendered to the client.

Can you please help thecodist, t is very much appreciated, thank you.

kind regards
darrylf290567
viewkitdetailES.asp (Caller Page):
 
 
<script type="text/javascript" language="JavaScript">
<!-- Hide
/*
function displayRenderTime()
{
	var renderStopTime;
	var theDate2;
	theDate2= new Date();
 
	renderStopTime = theDate2.getTime();
 
	document.write("<br>renderStopTime=" + renderStopTime + ", renderStartTime=" + renderStartTime);
	document.write("<br>The rendering time was " + ((renderStopTime - renderStartTime) / 1000) + " seconds.");
}
 
function logRenderTime()
{
	
		document.write("<iframe src='/inc/logClientTime.asp?time=" + ((renderStopTime - renderStartTime) / 1000) + "'  height=0 width=0>");
	
 
	document.write("</iframe>");
}
*/
// -->
</script>
 
<span class="debug">strAlertDate=</span><br>
<span class="debug">cookie=<br></span><br>
<span class="debug">strAlertDate=<br></span><br>
 
 
<script type="text/javascript" language="JavaScript">
<!-- Hide
// for the rendering Time logger
var renderStartTime;
var theDate;
	theDate =  new Date();
	renderStartTime = theDate.getTime();
 
 
 
// -->
</script>
 
<span class="debug">gettimeForSecurity() 14/2/2008 23:11:05 EST       </span><br>
<span class="debug">session timeout14/2/2008 23:10:20 EST       </span><br>
<span class="debug">gettimeforsecurity - session timeout =1</span><br>
<span class="debug">re setting session timeout to current time</span><br>
 
 
<html>
	<head>
		<title>
		 MyI - Inventory Management System
 
		</title>
<style>
		a, A:link, a:visited, a:active
			{color: #0000aa; text-decoration: none; font-family: Tahoma, Verdana; font-size: 11px}
		A:hover
			{color: #ff0000; text-decoration: none; font-family: Tahoma, Verdana; font-size: 11px}
		p, tr, td, ul, li
			{color: #000000; font-family: Tahoma, Verdana; font-size: 11px}
		.header1, h1
			{color: #ffffff; background: #4682B4; font-weight: bold; font-family: Tahoma, Verdana; font-size: 13px; margin: 0px; padding: 2px;}
		.header2, h2
			{color: #000000; background: #DBEAF5; font-weight: bold; font-family: Tahoma, Verdana; font-size: 12px;}
		.intd
			{color: #000000; font-family: Tahoma, Verdana; font-size: 11px; padding-left: 15px;}
		.btn
			{color: #000066; font-family: Tahoma, Verdana; font-size: 13px; background: #D6E7EF; border-bottom: 1px solid #104A7B; border-right: 1px solid #104A7B; border-left: 1px solid #AFC4D5; border-top: 1px solid #AFC4D5; text-decoration:none; cursor: hand;}
</style>
 
	<script language="JavaScript" src="/inc/menu_files/calendar.js"></script>
	<script language="JavaScript" src="/inc/menu_files/menu.js"></script>
		<script language="JavaScript">
var MENU_ITEMS_XP = [
[wrap_root('<font color=white><b>Admin</b></font>'), null, {'sw' : 68}, 
[wrap_parent('DPC Functions'), null, null, 
[wrap_child('User History'), '/admin/userhistory.asp'  ],
[wrap_child('Verify Addresses'), '/mail/qaviewlist1.asp'  ]
],
[wrap_parent('Security'), null, null,
[wrap_child('My Options'), '/reports/mysecurity.asp'  ],
[wrap_child('Secure Server'), 'https://www.myinventory.com.au/secureMode.asp'  ]
],
[wrap_parent('Freight'), null, null, 
[wrap_child('View Manifests'), '/admin/ViewManifests.asp'  ],
[wrap_child('Create Con-note'), '/orders/selectCarrierForConNote.asp'  ]
],
[wrap_parent('Stock Control'), null, null,
[wrap_child('Stocktake'), '/admin/stocktake1.asp'  ],
[wrap_child('Receive Stock'), '/admin/receive1.asp'  ],
[wrap_child('Express Receive'), '/admin/receiveexpress1.asp'  ],
[wrap_child('Receive Kit'), '/admin/receive1.asp?kitreceival=true'  ]
],
[wrap_child('Kit Management'), '/admin/viewkitdetailES.asp'  ],
[wrap_child('User Access Control'), '/useraccess/useraccess.asp'  ],
[wrap_child('Cost Centers'), '/admin/costcentres.asp'  ],
[wrap_child('Categories'), '/admin/categories.asp'  ],
[wrap_child('Debug Off'), '/debug.asp?toggle=off'],
[wrap_child('Re Authenticate'), '/reauth.asp'  ],
[wrap_child('Change In Production'), '/admin/ProductionEdit1.asp'  ],
[wrap_child('Change Unit Cost'), '/admin/unitcostEdit1.asp'  ],
[wrap_child('Change Reorder Level'), '/admin/reorderEdit1.asp'  ]
],
[wrap_root('<font color=white><b>Inventory</b></font>'), null, {'sw' : 88}, 
[wrap_child('Create New Item'), '/inv/createitemaES.asp'    ],
[wrap_child('Display Stock List'), '/inv/stocklista.asp'  ],
[wrap_child('Display Stock Tree'), '/inv/stocktree.asp'   ]
],
[wrap_root('<font color=white><b>Orders</b></font>'), null, {'sw' : 68}, 
[wrap_child('Order Stock'), '/orders/order1.asp'  ],
[wrap_child('Order Stock (Express)'), '/orders/express1.asp'  ]
],
[wrap_root('<font color=white><b>Reports</b></font>'), null, {'sw' : 68}, 
[wrap_parent('Order Reports'), null, null, 
[wrap_child('My Orders'), '/reports/myorders.asp?dateoption=1'  ],
[wrap_child('Open Orders'), '/reports/openordersES.asp'  ],
[wrap_child('Recently Closed'), '/reports/recentorders.asp'  ]
],
[wrap_child('Deleted Stock Items'), '/reports/DeletedStockItemReport.asp'  ],
[wrap_child('Shortage'), '/reports/shortage.asp'  ],
[wrap_child('Slow Movers'), '/reports/slowmover.asp'  ],
[wrap_child('In Production'), '/reports/inproduction.asp'  ],
[wrap_child('Product'), '/reports/productreport.asp'  ],
[wrap_child('Stock Availability'), '/reports/stockallwarehousea.asp'],
[wrap_child('Stock On Hand'), '/reports/stockonhand.asp'  ],
[wrap_child('Price List'), '/reports/pricelist.asp?allcategories=true'  ],
[wrap_child('Order Number'), '/reports/ordernumreport.asp'  ],
[wrap_child('Report Recipients'), '/reports/reportrecips.asp'  ]
],
[wrap_root('<font color=white><b>Account</b></font>'), null, {'sw' : 68}, 
[wrap_child('View Address Book'), '/account/viewbook.asp'  ],
[wrap_child('Change Password'), '/account/chgpass.asp'  ]
]
];
 
	var ii0 = new Image(); ii0.src = '../icons/arr.gif';
	var ii1 = new Image(); ii1.src = '../icons/i.gif';
	var ii2 = new Image(); ii2.src = '../icons/n7.gif';
	var ii3 = new Image(); ii3.src = '../icons/m12.gif';
	var ii4 = new Image(); ii4.src = '../icons/o.gif';
	var ii5 = new Image(); ii5.src = '../icons/email.gif';
	var ii6 = new Image(); ii6.src = '../icons/icq.gif';
	var ii7 = new Image(); ii7.src = '../icons/yahoo.gif';
	var ii8 = new Image(); ii8.src = '../icons/aol.gif';
	var ii9 = new Image(); ii9.src = 'menu_files/pixel.gif';
function wrap_parent (text,icon) {
return [['<table cellpadding=1 cellspacing=0 border=0 width="100%"><tr><td bgcolor=#D1D6E6><img height=15 src=', icon !=null ? 'icons/' + icon: '/inc/menu_files/pixel.gif width=8', ' hspace=3></td><td width="100%"><table cellpadding=1 cellspacing=0 border=0 width=100% height=18><tr><td class=a0>&nbsp; ', text, '</td></tr></table></td><td><img src=/inc/icons/arr.gif width=4 height=7 align="middle" align=absmiddle hspace=3></td></tr></table>'].join(''),
['<table cellpadding=1 cellspacing=0 border=0 width=100% bgcolor=#D1D6E6><tr><td><table cellpadding=1 cellspacing=0 border=0 width=100% height=16 bgcolor=#D1D6E6><tr><td><img height=15 src=', icon !=null ? 'icons/' + icon: '/inc/menu_files/pixel.gif width=8', ' hspace=3></td><td width=100% class=a0>&nbsp; ', text, '</td><td><img src=/inc/icons/arr.gif width=4 height=7 align="middle" align=absmiddle hspace=3></td></tr></table></td></tr></table>'].join(''),
['<table cellpadding=1 cellspacing=0 border=0 width=100% bgcolor=#D1D6E6><tr><td><table cellpadding=1 cellspacing=0 border=0 width=100% height=16 bgcolor=#D1D6E6><tr><td><img height=15 src=', icon !=null ? 'icons/' + icon: '/inc/menu_files/pixel.gif width=8', ' hspace=3></td><td width=100% class=a0>&nbsp; ', text, '</td><td><img src=icons/arr.gif width=4 height=7 align="middle" align=absmiddle hspace=3></td></tr></table></td></tr></table>'].join('')
];
 }
function wrap_child (text,icon) {
return [['<table cellpadding=1 cellspacing=0 border=0 width="100%"><tr><td bgcolor=#D1D6E6><img height=15 src=', icon !=null ? 'icons/' + icon: '/inc/menu_files/pixel.gif width=8', ' hspace=3></td><td width="100%"><table cellpadding=1 cellspacing=0 border=0 width=100% height=18><tr><td class=a0>&nbsp; ', text, '</td></tr></table></td></tr></table>'].join(''),
['<table cellpadding=1 cellspacing=0 border=0 width=100% bgcolor=#D1D6E6><tr><td><table cellpadding=1 cellspacing=0 border=0 width=100% height=16 bgcolor=#D1D6E6><tr><td><img height=15 src=', icon !=null ? 'icons/' + icon: '/inc/menu_files/pixel.gif width=8', ' hspace=3></td><td width=99% class=a0>&nbsp; ', text, '</td></tr></table></td></tr></table>'].join(''),
['<table cellpadding=1 cellspacing=0 border=0 width=100% bgcolor=#D1D6E6><tr><td><table cellpadding=1 cellspacing=0 border=0 width=100% height=16 bgcolor=#D1D6E6><tr><td><img height=15 src=', icon !=null ? 'icons/' + icon: '/inc/menu_files/pixel.gif width=8', ' hspace=3></td><td width=99% class=a0>&nbsp; ', text, '</td></tr></table></td></tr></table>'].join('')
];
 }
function wrap_root (text) {
return [
'<table cellpadding=1 cellspacing=1 border=0 width="100%"><tr><td><table cellpadding=0 cellspacing=0 border=0 width=100% height=13><tr><td width=100% class=a0 align="center">&nbsp; ' + text + ' &nbsp;</td></tr></table></td></tr></table>',
'<table cellpadding=1 cellspacing=1 border=0 width=100% bgcolor=#D1D6E6><tr><td><table cellpadding=0 cellspacing=0 border=0 width=100% height=15><tr><td width=100% class=a1 align="center">&nbsp; ' + text + ' &nbsp;</td></tr></table></td></tr></table>',
'<table cellpadding=1 cellspacing=1 border=0 width=100% bgcolor=#D1D6E6><tr><td><table cellpadding=0 cellspacing=0 border=0 width=100% height=15><tr><td width=100% class=a1 align="center">&nbsp; ' + text + ' &nbsp;</td></tr></table></td></tr></table>'
];
 } 
 
</script>
 
		<script language="JavaScript" src="/inc/menu_files/template.js"></script>
		<link rel="stylesheet" href="/inc/menu_files/menu.css">
		<link rel=stylesheet type="text/css" href="/inc/style.css">
 
 
 
</head>
 
<body BGCOLOR="#FFFFFF" TEXT="#000000" LEFTMARGIN="5" TOPMARGIN="5" MARGINWIDTH="5" MARGINHEIGHT="5"  >
 
<table width="750" border=0 cellspacing=0 cellpadding=0>
		<tr valign=top>
 
		<td rowspan=3>
			<table width="250" height="90" cellspacing=0 cellpadding=3 border=0 style="BORDER-TOP: #D1D6E6 1px solid; BORDER-LEFT: #D1D6E6 1px solid; BORDER-RIGHT: #D1D6E6 1px solid; BORDER-BOTTOM: #D1D6E6 1px solid;">
 
			<tr>
 
 
			<td  align="left" valign="top" width=75>
<span style="font-weight: bold;">Selected<br>Warehouse&nbsp;&nbsp;</span>
</td>
<td bgcolor="#F2F2F2" align="left"  nowrap valign="top" style="BORDER-BOTTOM: #FFFFFF 1px GROOVE;">
<a href="/chgwarehouse.asp" >EquipWarehouseTest</a>
&nbsp;&nbsp;</td>
 
			</tr>
			<tr valign=top>
		<td  align="left" nowrap valign="top" >
<span style="font-weight: bold;">Client</span>
</td>
<td bgcolor="#F2F2F2" align="left"  nowrap valign="top" style="BORDER-BOTTOM: #FFFFFF 1px GROOVE;">
<a href="/chgclient.asp" >EquipSuperClientTest1</a>
&nbsp;&nbsp;</td>
 
			</tr>
 
 
			<tr>
 
			<td valign=top>
							<span style="font-weight: bold;">Logout</span>
				</td>
			<td align="left" bgcolor="#F2F2F2" nowrap valign="top" style="BORDER-BOTTOM: #FFFFFF 1px GROOVE;">	<a href="/logout.asp" >Logout</a></td>
 
			</tr>
 
			<tr>
 
			<td  align="left" nowrap valign="top" >
				<span style="font-weight: bold;">Lookup</span>
			</td>
			<td  bgcolor="#F2F2F2" align="left">
				<a href="/lookup.asp"><img src="/images/lookup.gif" border=0></a>
			</td>
			</tr>
		</table>
 
		</td>
 
		<td rowspan=3 width=5>
			<img src="/img/singlepx.gif" height=5 width=5>
		</td>
 
		<td valign=center align=center>
		<span class="debug">d:\warehouse\Data Area\brands\banner-EquipSuperClientTest1.gif</span><br>
<a href="http://www.myinventory.com.au" target="_a"><img width=340 height=60 src="/brands/banner-myi.gif" border=1></a>
 
 
		</td>
 
		<td><img src="/img/singlepx.gif" height=5 width=5></td>
 
		<td align=right bgcolor="#F2F2F2" width=110 style="BORDER-TOP: #D1D6E6 1px solid; BORDER-LEFT: #D1D6E6 1px solid; BORDER-RIGHT: #D1D6E6 1px solid; BORDER-BOTTOM: #D1D6E6 1px solid;"">
			<iframe src="/inc/lastorderiframe.asp" width="110" bgcolor="#FFFFFF" height="39" frameborder="0" scrolling="no" marginheight="0" marginwidth="0">
				Sorry - your browser does not support iframes.
			</iframe>
		</td>
		<tr height=2><td colspan=3 height=2><img src="/img/singlepx.gif" height=5></td></tr>
		</tr>
 
		<tr valign=bottom>
 
			<td colspan=3 align=right>
			<script language="JavaScript">
						var MENU_FRAMES = [
							['header',],
							['main']
						]
 
							<!--
							new menu (MENU_ITEMS_XP, MENU_POS_XP, {'frames' : MENU_FRAMES, 'key' : 'myMenuGold'});
							//-->
		</script>
			</td>
		</tr>
 
<script language=javascript>
	<!-- Hide
	function Crmchangeclient(eControl) {
		if (eControl.value != 0) {
			document.ChangeClient.submit();
		}
	}
	// End Hide -->
</script>
 
</td>
</tr>
</form>
 
		</table>
 
 
		<p>
 
<table width=750 border=0 cellpadding=0 cellspacing=0>
		<tr valign=top>
			<td width=10>
				&nbsp;
			</td>
 
 
			<td width=100% class="bodytext">
 
<!-- main page content -->
 
		<span class="bodyhead">View Detail of Kits</span><p><p>
 
<script type="text/javascript" language="JavaScript">
<!--
 
function submitconfirm(Childid, Parentid,childCount)
{
	if(confirm('Are you sure you want to delete this product from the Kit?')) {
		window.location = '/admin/viewkitdetailES.asp?name=&type=1&chid=' + Childid + '&id=' + Parentid + '&cc=' + childCount;
	}
}
 
function addtokit(stockid, kitname, newFlag) {
	var myBars = 'directories=no,location=no,menubar=no,status=no,';
	myBars += 'titlebar=no,toolbar=no';
	var myOptions = 'scrollbars=yes,width=650,height=500,resizeable=no';
	var myFeatures = myBars + ',' + myOptions;
	var openURL = 'addkitproductES.asp?'
	openURL += 'stockid=' + stockid + '&name=' + kitname + '&newflag=' + newFlag
	newWin = open(openURL, 'mydoc', myFeatures);
	newWin.focus();
	newWin.document.close();
}
 
function addtokit2(KitIdArray, kitname, newFlag) {
	var myBars = 'directories=no,location=no,menubar=no,status=no,';
	myBars += 'titlebar=no,toolbar=no';
	var myOptions = 'scrollbars=yes,width=650,height=500,resizeable=no';
	var myFeatures = myBars + ',' + myOptions;
	var openURL = 'addkitproductES.asp?'
	openURL += 'stockid=' + KitIdArray + '&name=' + kitname + '&newflag=' + newFlag
	newWin = open(openURL, 'mydoc', myFeatures);
	newWin.focus();
	newWin.document.close();
}
 
function editkitqty(parentid, stockid, kitQty, kitName) {
	var myBars = 'directories=no,location=no,menubar=no,status=no,';
	myBars += 'titlebar=no,toolbar=no';
	var myOptions = 'scrollbars=no,width=240,height=250,resizeable=no,left=400,top=300,screenX=100,screenY=100';
	var myFeatures = myBars + ',' + myOptions;
	var openURL = 'editkitqtyES.asp?'
	openURL += 'parentid=' + parentid
	openURL += '&stockid=' + stockid
	openURL += '&oldqty=' + kitQty
	openURL += '&name=' + kitName
	newWin = open(openURL, 'mydoc', myFeatures);
	newWin.focus();
	newWin.document.close();
}
//-->
</script>
 
<span class="debug"></span><br>
<span class="debug">SELECT * FROM nkitSummary WHERE ClientID = 102</span><br>
<span class="debug">kitName= KIT1</span><br>
<table cellspacing=2 cellpadding=2 border=0>
<tr valign=top>
<td> <span class="bodyhead">Kit Name:</span></td>
<td> <span class="bodyhead">KIT1</span></td>
</tr>
</table>
<span class="debug">kitID= 19593</span><br>
<span class="debug">KitIdArray(0)= 19593</span><br>
<span class="debug">KitIdArray(1)= </span><br>
<span class="debug">KitIdArray(2)= </span><br>
<span class="debug">KitIdArray(3)= </span><br>
<span class="debug">KitIdArray(4)= </span><br>
<span class="debug">KitIdArray(5)= </span><br>
<span class="debug">KitIdArray(6)= </span><br>
<span class="debug">KitIdArray(7)= </span><br>
<span class="debug">KitIdArray(8)= </span><br>
<span class="debug">KitIdArray(9)= </span><br>
<span class="debug">SELECT * FROM nStockItemBelongToKitES WHERE ClientID = 102 AND ParentID = 19593</span><br>
<p>
<a href="javascript:addtokit2('19593,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,','KIT1','False')">Add a new component</a><p>
<table cellspacing=2 cellpadding=2 border=0>
<tr valign=top>
<td class="bodytext">&nbsp;</td>
<td class="tablehead">Component Code</td>
<td class="tablehead">Component Name</td>
<td class="tablehead">Qty</td>
<td class="tablehead">UnitCost</td>
<td class="tablehead">Available</td>
</tr>
<tr valign=top>
<td class="small" width=10 style="background-color:#ffffff;">
<a href="javascript:submitconfirm(19583,19593,6)"><img align=top src="../img/trash16.gif" border=0></a>
</td>
<td class="small">
<a href="/inv/edititemES.asp?id=19583&stage=1">ITEM1</a>&nbsp;</td>
<span class="debug">SELECT * FROM nOrder2 WHERE StockID = 19583 AND WarehouseID=109</span><br>
<td class="small">ITEM1&nbsp;</td>
<td class="small" style="color: green;" align="right"><a href="javascript:editkitqty(19593, 19583, 100, '');">100</a>&nbsp;</td>
<td class="small" align="right">2&nbsp;</td>
<td class="small" align="right">400&nbsp;</td>
<span class="debug">4</span><br>
</tr>
<tr valign=top style="background-color:#F2F2F2;">
<td class="small" width=10 style="background-color:#ffffff;">
<a href="javascript:submitconfirm(19584,19593,6)"><img align=top src="../img/trash16.gif" border=0></a>
</td>
<td class="small">
<a href="/inv/edititemES.asp?id=19584&stage=1">ITEM1B</a>&nbsp;</td>
<span class="debug">SELECT * FROM nOrder2 WHERE StockID = 19584 AND WarehouseID=109</span><br>
<td class="small">ITEM1B&nbsp;</td>
<td class="small" style="color: green;" align="right"><a href="javascript:editkitqty(19593, 19584, 100, '');">100</a>&nbsp;</td>
<td class="small" align="right">1.5&nbsp;</td>
<td class="small" align="right">500&nbsp;</td>
<span class="debug">5</span><br>
</tr>
<tr valign=top>
<td class="small" width=10 style="background-color:#ffffff;">
<a href="javascript:submitconfirm(19614,19593,6)"><img align=top src="../img/trash16.gif" border=0></a>
</td>
<td class="small">
<a href="/inv/edititemES.asp?id=19614&stage=1">00001</a>&nbsp;</td>
<span class="debug">SELECT * FROM nOrder2 WHERE StockID = 19614 AND WarehouseID=109</span><br>
<td class="small">EQUIPTEST ITEM&nbsp;</td>
<td class="small" style="color: red;" align="right">* &nbsp;<a href="javascript:editkitqty(19593, 19614, 1, '');">1</a>&nbsp;</td>
<td class="small" align="right">0&nbsp;</td>
<td class="small" align="right">0&nbsp;</td>
<span class="debug">0</span><br>
</tr>
<tr valign=top style="background-color:#F2F2F2;">
<td class="small" width=10 style="background-color:#ffffff;">
<a href="javascript:submitconfirm(19591,19593,6)"><img align=top src="../img/trash16.gif" border=0></a>
</td>
<td class="small">
<a href="/inv/edititemES.asp?id=19591&stage=1">ITEM3C</a>&nbsp;</td>
<span class="debug">SELECT * FROM nOrder2 WHERE StockID = 19591 AND WarehouseID=109</span><br>
<td class="small">ITEM3C&nbsp;</td>
<td class="small" style="color: green;" align="right"><a href="javascript:editkitqty(19593, 19591, 10, '');">10</a>&nbsp;</td>
<td class="small" align="right">2&nbsp;</td>
<td class="small" align="right">500&nbsp;</td>
<span class="debug">50</span><br>
</tr>
<tr valign=top>
<td class="small" width=10 style="background-color:#ffffff;">
<a href="javascript:submitconfirm(19586,19593,6)"><img align=top src="../img/trash16.gif" border=0></a>
</td>
<td class="small">
<a href="/inv/edititemES.asp?id=19586&stage=1">ITEM2A</a>&nbsp;</td>
<span class="debug">SELECT * FROM nOrder2 WHERE StockID = 19586 AND WarehouseID=109</span><br>
<td class="small">ITEM2A&nbsp;</td>
<td class="small" style="color: green;" align="right"><a href="javascript:editkitqty(19593, 19586, 20, '');">20</a>&nbsp;</td>
<td class="small" align="right">3&nbsp;</td>
<td class="small" align="right">500&nbsp;</td>
<span class="debug">25</span><br>
</tr>
<tr valign=top style="background-color:#F2F2F2;">
<td class="small" width=10 style="background-color:#ffffff;">
<a href="javascript:submitconfirm(19590,19593,6)"><img align=top src="../img/trash16.gif" border=0></a>
</td>
<td class="small">
<a href="/inv/edititemES.asp?id=19590&stage=1">ITEM3B</a>&nbsp;</td>
<span class="debug">SELECT * FROM nOrder2 WHERE StockID = 19590 AND WarehouseID=109</span><br>
<td class="small">ITEM3B&nbsp;</td>
<td class="small" style="color: green;" align="right"><a href="javascript:editkitqty(19593, 19590, 50, '');">50</a>&nbsp;</td>
<td class="small" align="right">1.5&nbsp;</td>
<td class="small" align="right">500&nbsp;</td>
<span class="debug">10</span><br>
</tr>
<p class="bodytext"> Based on the current available stock a total of <span style="color: green;"> <b>4</b> </span> kits can be created.
<tr valign=top>
<td class="bodytext" align=right>&nbsp;</td>
<td class="bodytext" align=right>&nbsp;</td>
<td class="bodytext" colspan=2><b>Total Kit Cost</b></td>
<td class="bodytext" align=right>505.00</td>
</tr>
<span class="debug">kitName= KIT2</span><br>
<table cellspacing=2 cellpadding=2 border=0>
<tr valign=top>
<td> <span class="bodyhead">Kit Name:</span></td>
<td> <span class="bodyhead">KIT2</span></td>
</tr>
</table>
<span class="debug">kitID= 19594</span><br>
<span class="debug">KitIdArray(0)= 19593</span><br>
<span class="debug">KitIdArray(1)= 19594</span><br>
<span class="debug">KitIdArray(2)= </span><br>
<span class="debug">KitIdArray(3)= </span><br>
<span class="debug">KitIdArray(4)= </span><br>
<span class="debug">KitIdArray(5)= </span><br>
<span class="debug">KitIdArray(6)= </span><br>
<span class="debug">KitIdArray(7)= </span><br>
<span class="debug">KitIdArray(8)= </span><br>
<span class="debug">KitIdArray(9)= </span><br>
<span class="debug">SELECT * FROM nStockItemBelongToKitES WHERE ClientID = 102 AND ParentID = 19594</span><br>
<p>
<a href="javascript:addtokit2('19593,19594,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,','KIT2','False')">Add a new component</a><p>
<table cellspacing=2 cellpadding=2 border=0>
<tr valign=top>
<td class="bodytext">&nbsp;</td>
<td class="tablehead">Component Code</td>
<td class="tablehead">Component Name</td>
<td class="tablehead">Qty</td>
<td class="tablehead">UnitCost</td>
<td class="tablehead">Available</td>
</tr>
<tr valign=top>
<td class="small" width=10 style="background-color:#ffffff;">
<a href="javascript:submitconfirm(19586,19594,2)"><img align=top src="../img/trash16.gif" border=0></a>
</td>
<td class="small">
<a href="/inv/edititemES.asp?id=19586&stage=1">ITEM2A</a>&nbsp;</td>
<span class="debug">SELECT * FROM nOrder2 WHERE StockID = 19586 AND WarehouseID=109</span><br>
<td class="small">ITEM2A&nbsp;</td>
<td class="small" style="color: green;" align="right"><a href="javascript:editkitqty(19594, 19586, 100, '');">100</a>&nbsp;</td>
<td class="small" align="right">3&nbsp;</td>
<td class="small" align="right">500&nbsp;</td>
<span class="debug">5</span><br>
</tr>
<tr valign=top style="background-color:#F2F2F2;">
<td class="small" width=10 style="background-color:#ffffff;">
<a href="javascript:submitconfirm(19587,19594,2)"><img align=top src="../img/trash16.gif" border=0></a>
</td>
<td class="small">
<a href="/inv/edititemES.asp?id=19587&stage=1">ITEM2B</a>&nbsp;</td>
<span class="debug">SELECT * FROM nOrder2 WHERE StockID = 19587 AND WarehouseID=109</span><br>
<td class="small">ITEM2B&nbsp;</td>
<td class="small" style="color: green;" align="right"><a href="javascript:editkitqty(19594, 19587, 200, '');">200</a>&nbsp;</td>
<td class="small" align="right">1.5&nbsp;</td>
<td class="small" align="right">500&nbsp;</td>
<span class="debug">2</span><br>
</tr>
<p class="bodytext"> Based on the current available stock a total of <span style="color: green;"> <b>5</b> </span> kits can be created.
<tr valign=top>
<td class="bodytext" align=right>&nbsp;</td>
<td class="bodytext" align=right>&nbsp;</td>
<td class="bodytext" colspan=2><b>Total Kit Cost</b></td>
<td class="bodytext" align=right>1,105.00</td>
</tr>
<span class="debug">kitName= KIT3</span><br>
<table cellspacing=2 cellpadding=2 border=0>
<tr valign=top>
<td> <span class="bodyhead">Kit Name:</span></td>
<td> <span class="bodyhead">KIT3</span></td>
</tr>
</table>
<span class="debug">kitID= 19595</span><br>
<span class="debug">KitIdArray(0)= 19593</span><br>
<span class="debug">KitIdArray(1)= 19594</span><br>
<span class="debug">KitIdArray(2)= 19595</span><br>
<span class="debug">KitIdArray(3)= </span><br>
<span class="debug">KitIdArray(4)= </span><br>
<span class="debug">KitIdArray(5)= </span><br>
<span class="debug">KitIdArray(6)= </span><br>
<span class="debug">KitIdArray(7)= </span><br>
<span class="debug">KitIdArray(8)= </span><br>
<span class="debug">KitIdArray(9)= </span><br>
<span class="debug">SELECT * FROM nStockItemBelongToKitES WHERE ClientID = 102 AND ParentID = 19595</span><br>
<p>
<a href="javascript:addtokit2('19593,19594,19595,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,','KIT3','False')">Add a new component</a><p>
<table cellspacing=2 cellpadding=2 border=0>
<tr valign=top>
<td class="bodytext">&nbsp;</td>
<td class="tablehead">Component Code</td>
<td class="tablehead">Component Name</td>
<td class="tablehead">Qty</td>
<td class="tablehead">UnitCost</td>
<td class="tablehead">Available</td>
</tr>
<tr valign=top>
<td class="small" width=10 style="background-color:#ffffff;">
<a href="javascript:submitconfirm(19589,19595,3)"><img align=top src="../img/trash16.gif" border=0></a>
</td>
<td class="small">
<a href="/inv/edititemES.asp?id=19589&stage=1">ITEM3A</a>&nbsp;</td>
<span class="debug">SELECT * FROM nOrder2 WHERE StockID = 19589 AND WarehouseID=109</span><br>
<td class="small">ITEM3A&nbsp;</td>
<td class="small" style="color: green;" align="right"><a href="javascript:editkitqty(19595, 19589, 100, '');">100</a>&nbsp;</td>
<td class="small" align="right">2.5&nbsp;</td>
<td class="small" align="right">500&nbsp;</td>
<span class="debug">5</span><br>
</tr>
<tr valign=top style="background-color:#F2F2F2;">
<td class="small" width=10 style="background-color:#ffffff;">
<a href="javascript:submitconfirm(19590,19595,3)"><img align=top src="../img/trash16.gif" border=0></a>
</td>
<td class="small">
<a href="/inv/edititemES.asp?id=19590&stage=1">ITEM3B</a>&nbsp;</td>
<span class="debug">SELECT * FROM nOrder2 WHERE StockID = 19590 AND WarehouseID=109</span><br>
<td class="small">ITEM3B&nbsp;</td>
<td class="small" style="color: green;" align="right"><a href="javascript:editkitqty(19595, 19590, 100, '');">100</a>&nbsp;</td>
<td class="small" align="right">1.5&nbsp;</td>
<td class="small" align="right">500&nbsp;</td>
<span class="debug">5</span><br>
</tr>
<tr valign=top>
<td class="small" width=10 style="background-color:#ffffff;">
<a href="javascript:submitconfirm(19591,19595,3)"><img align=top src="../img/trash16.gif" border=0></a>
</td>
<td class="small">
<a href="/inv/edititemES.asp?id=19591&stage=1">ITEM3C</a>&nbsp;</td>
<span class="debug">SELECT * FROM nOrder2 WHERE StockID = 19591 AND WarehouseID=109</span><br>
<td class="small">ITEM3C&nbsp;</td>
<td class="small" style="color: green;" align="right"><a href="javascript:editkitqty(19595, 19591, 100, '');">100</a>&nbsp;</td>
<td class="small" align="right">2&nbsp;</td>
<td class="small" align="right">500&nbsp;</td>
<span class="debug">5</span><br>
</tr>
<p class="bodytext"> Based on the current available stock a total of <span style="color: green;"> <b>5</b> </span> kits can be created.
<tr valign=top>
<td class="bodytext" align=right>&nbsp;</td>
<td class="bodytext" align=right>&nbsp;</td>
<td class="bodytext" colspan=2><b>Total Kit Cost</b></td>
<td class="bodytext" align=right>1,705.00</td>
</tr>
</table>
<span class="bodytext" style="font-size: 10px;">
<p>processing time: 2.984 seconds
 
 
<script type="text/javascript" language="JavaScript">
<!-- Hide
 
var renderStopTime;
	var theDate2;
	theDate2= new Date();
 
	renderStopTime = theDate2.getTime();
 
	
		document.write("<br>renderStopTime=" + renderStopTime + ", renderStartTime=" + renderStartTime);
	
 
	document.write("<br>display time:  " + ((renderStopTime - renderStartTime) / 1000) + " seconds.");
 
	
		document.write("<iframe src='/inc/logRenderTime.asp?time=" + ((renderStopTime - renderStartTime) / 1000) + "'  height=100 width=100>");
	
 
	document.write("</iframe>");
 
// -->
</script>
 
 
 
<!-- end main content -->
				</td>
			</tr>
		</table>
			
 
	</body>
</html>
 
addKitproductES.asp (Callee page):
 
 
<script type="text/javascript" language="JavaScript">
<!-- Hide
/*
function displayRenderTime()
{
	var renderStopTime;
	var theDate2;
	theDate2= new Date();
 
	renderStopTime = theDate2.getTime();
 
	document.write("<br>renderStopTime=" + renderStopTime + ", renderStartTime=" + renderStartTime);
	document.write("<br>The rendering time was " + ((renderStopTime - renderStartTime) / 1000) + " seconds.");
}
 
function logRenderTime()
{
	
		document.write("<iframe src='/inc/logClientTime.asp?time=" + ((renderStopTime - renderStartTime) / 1000) + "'  height=0 width=0>");
	
 
	document.write("</iframe>");
}
*/
// -->
</script>
 
<span class="debug">strAlertDate=</span><br>
<span class="debug">cookie=<br></span><br>
<span class="debug">strAlertDate=<br></span><br>
 
 
<script type="text/javascript" language="JavaScript">
<!-- Hide
// for the rendering Time logger
var renderStartTime;
var theDate;
	theDate =  new Date();
	renderStartTime = theDate.getTime();
 
 
 
// -->
</script>
 
<span class="debug">gettimeForSecurity() 14/2/2008 23:16:25 EST       </span><br>
<span class="debug">session timeout14/2/2008 23:16:21 EST       </span><br>
<span class="debug">gettimeforsecurity - session timeout =0</span><br>
<span class="debug">re setting session timeout to current time</span><br>
 
 
<html>
	<head>
	<title>
 
	</title>
	<link rel=stylesheet type="text/css" href="/inc/style.css">
	</head>
	<body class="bodytext">
 
<!-- main page content -->
 
<script language="JavaScript">
<!-- Hide
 
var ACProdArrAcc = new Array()
 
function ProdAcc(IDAcc, PNameAcc) {
	this.IDAcc		= IDAcc
	this.PNameAcc	= PNameAcc
}
 
 
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(19614,'EQUIPTEST ITEM- ');
 
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(19583,'ITEM1- ');
 
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(19584,'ITEM1B- ');
 
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(19585,'ITEM1C- ');
 
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(19586,'ITEM2A- ');
 
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(19587,'ITEM2B- ');
 
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(19588,'ITEM2C- ');
 
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(19589,'ITEM3A- ');
 
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(19590,'ITEM3B- ');
 
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(19591,'ITEM3C- ');
 
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(19592,'KIT1- ');
 
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(19593,'KIT1- ');
 
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(19594,'KIT2- ');
 
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(19595,'KIT3- ');
 
 
 
 
	var ResultsAcc;
	var HTMLAcc;
	function FindProductAcc(zoneAcc, event) {
 
		ResultsAcc = 0;
		HTMLAcc	= "";
 
		resultDivAcc = document.getElementById('resultAcc');
		resultTitleDivAcc = document.getElementById('resultTitleAcc');
		resultMessageDivAcc = document.getElementById('resultMessageAcc');
		resultListDivAcc = document.getElementById('resultListAcc');
		ACBAcc = document.searchAcc_form.searchAcc.value;
 
		for (i=0; i< ACProdArrAcc.length; i++) {
			if(ACBAcc.length > 0){
				var PName = ACProdArrAcc[i].PNameAcc.replace(/'/g, "\"'\"");
 
				if (PName.toLowerCase().substr(0, ACBAcc.length) == ACBAcc.toLowerCase() || PName.toLowerCase().indexOf(ACBAcc.toLowerCase()) > -1) {
					HTMLAcc = HTMLAcc + "<a href='javascript:ReturnSub(" + 19593,19594,19595 + ", " + ACProdArrAcc[i].IDAcc + ")' class='link'>" + PName + "</a><br>"
					ResultsAcc += 1;
				}
			}
		}
 
		if (ResultsAcc == 0){
			resultDivAcc.style.display = 'block';
			if (ACBAcc.length > 0) {
				resultMessageDivAcc.style.display = 'block';
			} else {
				resultMessageDivAcc.style.display = 'none';
			}
			resultTitleDivAcc.style.display = 'none';
			resultListDivAcc.style.display = 'none';
			resultListDivAcc.innerHTML = "";
			resultNum.style.display = 'none';
		}
		else{
			resultDivAcc.style.display = 'block';
			resultMessageDivAcc.style.display = 'none';
			resultTitleDivAcc.style.display = 'block';
			resultListDivAcc.style.display = 'block';
			resultListDivAcc.innerHTML = HTMLAcc;
			resultNum.style.display = 'block';
			resultNum.innerHTML = ResultsAcc + ' products found.<p>';
		}
	}
 
	function submitAccFinder() {
		if (ResultsAcc >= 1) {
			var index = HTMLAcc.indexOf("'");
			strLocation = HTMLAcc.substr(index+1, HTMLAcc.indexOf("'", index+1)-(index+1));
			document.location.href = strLocation;
		}
		return false;
	}
 
	function ReturnSub(stockID, ChildID) {
		var regexp = /^(\d+)$/;
 
		if (regexp.test(document.searchAcc_form.newqty.value)) {
			if (document.searchAcc_form.newqty.value < 1) {
 
				window.alert("Product's quantity must be atleast 1");
		         	}
 
			else {
 
				window.opener.location='addkitdetailES.asp?parentID=' + stockID + '&newchildid=' + ChildID + '&newqty=' + document.searchAcc_form.newqty.value + '&newkit=' + 'False' + '&name=' + 'KIT3';
				window.opener.focus();
				self.close();
			     }
		}
		 else {
		window.alert("Quantity is either null or not a number");
	}
 
	}
-->
</script>
 
		<center><span class="bodyhead">Add a new component to KIT3</span><p>
<span class="debug">19593,19594,19595</span><br>
<FORM id=searchAcc_form style="MARGIN-BOTTOM: 0px" name=searchAcc_form onsubmit=return(submitAccFinder()); action="" method=get>
<table border=0 cellspacing=0 cellpadding=2 width="95%">
<tr>
<TD vAlign=top width=100 class="bodytext">Enter Quantity: <input name=newqty size=5 style="text-align:center;font-weight:bold;font-size:14px"></td><p>
<TD vAlign=top width=100 class="bodytext">
<b>Product Name</b><br>
<INPUT id=searchAcc onkeyup='FindProductAcc("pp", event)' style="BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; BORDER-LEFT: black 1px solid; BORDER-BOTTOM: black 1px solid" name=searchAcc>&nbsp;&nbsp;<p>
<DIV id=resultNum style="DISPLAY: none"></DIV>
<a href="javascript:window.close();">Cancel</a>
</TD>
<td class="bodytext">
<DIV id=resultAcc style="DISPLAY: none">
<TABLE cellSpacing=0 cellPadding=0 border=0>
<TR>
<TD vAlign=top class="bodytext">
<DIV id=resultTitleAcc 
style="DISPLAY: none"><b>Matching products (Name)</b></DIV>
<DIV id=resultListAcc 
style="DISPLAY: none"></DIV>
<DIV id=resultMessageAcc 
style="DISPLAY: none">Sorry, no matching products found.</DIV>
</td></tr>
</table>
</td></tr>
</table><p>
</form>
 
 
<!-- end main content -->
	</center></body>
</html>

Open in new window

0
 
darrylf290567Author Commented:
Hi thecodist,

this is what is passed into the url of the callee page:
http://www.myinventory.com.au/admin/addkitproductES.asp?stockid=19593,19594,19595&name=KIT3&newflag=False
should be all kit names and not just kit3.

kind regards
darrylf290567
0
 
thecodistCommented:
Ok, Here is what I am seeing: addkitdetailES.asp is setup to receive only a single stockID so it would need to be modified to handle a list of stockID's. In the ASP code section of that page you would retrieve the Request.Query("parentID") value and then split it into an array using the VBA Split function:
Dim aArray
aArray = Split(Request.Query("parentID"), ",")
Then you would loop through that array and process for each stockID:
Dim i
For i = 0 To UBound(aArray)
     stockID = aArray(i)
     'Perform whatever processing needs to be done here.
Next
I would also suggest renaming the appropriate variables, e.g. stockID to stockIDs, parentID to parentIDs for instance.
I will be out of the office the remainder of the day so I will have to check back tomorrow morning.
Good luck!
0
 
darrylf290567Author Commented:
Hi thecodist,

You did mean addkitproductES.asp and NOT addkitdetailES.asp? I will send you the asp code for the addkitproductES.asp page as well.
When you say:
In the ASP code section of that page you would retrieve the Request.Query("parentID") value and then split it into an array using the VBA Split function

I am passing in 3 values: I thought I would do a request on the KitIDArray and NOT the Request.Query("parentID") . Where are you getting that from?

Kind Regards
darrylf290567
0
 
thecodistCommented:
The FindProductAcc function is calling the ReturnSub function passing in 19593,19594,19595 as the stockID (I would change to stockIDs).
Next the ReturnSub fuctions is opening the addkitdetailES.asp passing in 19593,19594,19595 as the parentID (I would change to parentIDs).
That is why I suggested splitting parentID in the server-side VBScript code section of addkitdetailES.asp into a VB array and processing each entry in the array. I assume that addkitdetailES.asp is where the actual item is being added to each kit.
Let me know if this helps.
0
 
darrylf290567Author Commented:
Hi thecodist,

If I could give you the 3 asp files could you please fix it for me . I will attach the asp files in the code snippet for you. If you can fix this for me I am going to add another 50 points for your great help. I really appreciate this so much.

PLEASE CAN YOU PLEASE HAVE A look at it TODAY Thnakyou once again.

kindest regards
darrylf290567
First ASP Calling page which has the array being built up and then passed into a javascript function. In that javascript function the IDs are passed to the next asp page:
<!--#include file="../inc/adovbs.asp" -->
<!--#include file="../inc/std.asp" -->
<!--#include file="../inc/const.asp" -->
<!--#include file="../inc/securitycheck.asp" -->
 
<html>
	<head>
		<title>
		<% rw BrandName %>
		</title>
<!--#include file="../inc/commonmenuscripts.asp" -->
 
<table width=<% = ScreenWidth %> border=0 cellpadding=0 cellspacing=0>
		<tr valign=top>
			<td width=<% = TableSpacing %>>
				&nbsp;
			</td>
 
 
			<td width=<% = TableWidth %> class="bodytext">
 
<!-- main page content -->
 
		<span class="bodyhead">View Detail of Kits</span><p><p>
 
<script type="text/javascript" language="JavaScript">
<!--
 
function submitconfirm(Childid, Parentid,childCount)
{
	if(confirm('Are you sure you want to delete this product from the Kit?')) {
		window.location = '<% =CurrentURL & "?name=" & request("name") & "&type=1&chid=" %>' + Childid + '&id=' + Parentid + '&cc=' + childCount;
	}
}
 
function addtokit(stockid, kitname, newFlag) {
	var myBars = 'directories=no,location=no,menubar=no,status=no,';
	myBars += 'titlebar=no,toolbar=no';
	var myOptions = 'scrollbars=yes,width=650,height=500,resizeable=no';
	var myFeatures = myBars + ',' + myOptions;
	var openURL = 'addkitproductES.asp?'
	openURL += 'stockid=' + stockid + '&name=' + kitname + '&newflag=' + newFlag
	newWin = open(openURL, 'mydoc', myFeatures);
	newWin.focus();
	newWin.document.close();
}
 
function addtokit2(KitIdArray, kitname, newFlag) {
	var myBars = 'directories=no,location=no,menubar=no,status=no,';
	myBars += 'titlebar=no,toolbar=no';
	var myOptions = 'scrollbars=yes,width=650,height=500,resizeable=no';
	var myFeatures = myBars + ',' + myOptions;
	var openURL = 'addkitproductES.asp?'
	openURL += 'stockid=' + KitIdArray + '&name=' + kitname + '&newflag=' + newFlag
	newWin = open(openURL, 'mydoc', myFeatures);
	newWin.focus();
	newWin.document.close();
}
 
function editkitqty(parentid, stockid, kitQty, kitName) {
	var myBars = 'directories=no,location=no,menubar=no,status=no,';
	myBars += 'titlebar=no,toolbar=no';
	var myOptions = 'scrollbars=no,width=240,height=250,resizeable=no,left=400,top=300,screenX=100,screenY=100';
	var myFeatures = myBars + ',' + myOptions;
	var openURL = 'editkitqtyES.asp?'
	openURL += 'parentid=' + parentid
	openURL += '&stockid=' + stockid
	openURL += '&oldqty=' + kitQty
	openURL += '&name=' + kitName
	newWin = open(openURL, 'mydoc', myFeatures);
	newWin.focus();
	newWin.document.close();
}
//-->
</script>
 
<%
Dim KitArray(50)
Dim KitIdArray(50)
 
Dim rsStockItemBelongToKitES
Dim sqlStockItemBelongToKitES
Dim rsnkitSummary
Dim EditKitName
Dim sqlnkitSummary
Dim HowManyParentIDCount
 
StockID = request("stockid")
 
pdebug StockID
 
if request("new") then
 
	if security(sClientAdmin) then
		rw "<p class=""bodytext"">You must add at least 1 component to the Kit otherwise the Kit will not be created<P>"
 
		rw "<a href=""javascript:addtokit(" & StockID & ",'" & kitname & "','" & true & "')"">Add a new component</a><p>"
	end if
else
	set dbconn = Server.CreateObject("ADODB.Connection")
	dbconn.open ODBCsource
	if request("type") = 1  and security (sPowerUser) then 	' delete ID first
 
		delsqlkit = "DELETE FROM Kits WHERE parentid = " & request("id") & _
			" AND ChildID = " & request("chid")
		pdebug delsqlkit
		dbconn.execute(delsqlkit)
		Audit request("id"), "Kits ChildId " & request("chid") & " Deleted"		' log event
 
	else
		Session("KitID") = request("id")
	end if
 
	if request("cc") = 1 then ' last item deleted, no point showing kit detail - kit no longer exists
 
		'response.redirect("/admin/kitssummaryES.asp")
		response.redirect("/admin/viewkitdetailES.asp")
	else
		sqlnkitSummary = "SELECT * FROM nkitSummary WHERE ClientID = " & ClientID
		'kitListID = Session("KitID")
		
		PDebug sqlnkitSummary
		response.flush
 
		set rsnkitSummary = Server.createObject("ADODB.Recordset")
		rsnkitSummary.open  sqlnkitSummary , dbconn, adUseClient, adLockreadonly, adCmdText
				
		'get on with it
		if rsnkitSummary.eof then
				
			PrintError "There are no products in this kit.<p>"
		else
			'First loop to get the ParentID for a Kit
			do while not rsnkitSummary.eof
				EditKitName = rsnkitSummary("StockName")
				pdebug "kitName= " & EditKitName
				'display kit name
				rw "<table cellspacing=2 cellpadding=2 border=0>"
				rw "<tr valign=top>"
				rw "<td> <span class=""bodyhead"">Kit Name:</span></td>"
				rw "<td> <span class=""bodyhead"">" & EditKitName & "</span></td>"
				rw "</tr>"
				rw "</table>"
				kitListID = rsnkitSummary("ParentID")
				PDebug "kitID= " & kitListID
				'Takes care of 1st KitID
				If KitIdArray(0) = 0 Then
				   KitIdArray(0) = kitListID
				   'KitIdArray(0) = kitListID
				'Takes care of 2nd KitID
                                ElseIf KitIdArray(0) <> kitListID And KitIdArray(1) = 0 Then
				   KitIdArray(1) = kitListID
				'Takes care of 3rd KitID
				ElseIf KitIdArray(1) <> kitListID And KitIdArray(2) = 0 Then
				   KitIdArray(2) = kitListID
				'Takes care of 4th KitID
				ElseIf KitIdArray(1) <> kitListID And KitIdArray(2) <> kitListID And KitIdArray(3) = 0 Then
				   KitIdArray(3) = kitListID
				'Takes care of 5th KitID
				ElseIf KitIdArray(1) <> kitListID And KitIdArray(2) <> kitListID And KitIdArray(3) <> kitListID And KitIdArray(4) = 0 Then
				   KitIdArray(4) = kitListID
				'Takes care of 6th KitID
				ElseIf KitIdArray(1) <> kitListID And KitIdArray(2) <> kitListID And KitIdArray(3) <> kitListID And KitIdArray(4) <> kitListID And KitIdArray(5) = 0 Then
				   KitIdArray(5) = kitListID
				'Takes care of 7th KitID
				ElseIf KitIdArray(1) <> kitListID And KitIdArray(2) <> kitListID And KitIdArray(3) <> kitListID And KitIdArray(4) <> kitListID And KitIdArray(5) <> kitListID And KitIdArray(6) = 0 Then
				   KitIdArray(6) = kitListID
				'Takes care of 8th KitID
				ElseIf KitIdArray(1) <> kitListID And KitIdArray(2) <> kitListID And KitIdArray(3) <> kitListID And KitIdArray(4) <> kitListID And KitIdArray(5) <> kitListID And KitIdArray(6) <> kitListID And KitIdArray(7) = 0 Then
				   KitIdArray(7) = kitListID
				'Takes care of 9th KitID
				ElseIf KitIdArray(1) <> kitListID And KitIdArray(2) <> kitListID And KitIdArray(3) <> kitListID And KitIdArray(4) <> kitListID And KitIdArray(5) <> kitListID And KitIdArray(6) <> kitListID And KitIdArray(7) <> kitListID And KitIdArray(8) = 0 Then
				   KitIdArray(8) = kitListID
				'Takes care of 10th KitID
				ElseIf KitIdArray(1) <> kitListID And KitIdArray(2) <> kitListID And KitIdArray(3) <> kitListID And KitIdArray(4) <> kitListID And KitIdArray(5) <> kitListID And KitIdArray(6) <> kitListID And KitIdArray(7) <> kitListID And KitIdArray(8) <> kitListID And KitIdArray(9) = 0 Then
				   KitIdArray(9) = kitListID
				End If
				PDebug "KitIdArray(0)= " & KitIdArray(0)
				PDebug "KitIdArray(1)= " & KitIdArray(1)
				PDebug "KitIdArray(2)= " & KitIdArray(2)
				PDebug "KitIdArray(3)= " & KitIdArray(3)
				PDebug "KitIdArray(4)= " & KitIdArray(4)
				PDebug "KitIdArray(5)= " & KitIdArray(5)
				PDebug "KitIdArray(6)= " & KitIdArray(6)
				PDebug "KitIdArray(7)= " & KitIdArray(7)
				PDebug "KitIdArray(8)= " & KitIdArray(8)
				PDebug "KitIdArray(9)= " & KitIdArray(9)
				set rsStockItemBelongToKitES = server.createObject("adodb.recordset")
				'Now go ahead and get the stock components that make up a kit
				sqlStockItemBelongToKitES = "SELECT * FROM nStockItemBelongToKitES WHERE ClientID = " & ClientID & _
				" AND ParentID = " & kitListID
				pdebug sqlStockItemBelongToKitES
				rsStockItemBelongToKitES.open sqlStockItemBelongToKitES, dbconn, adUseClient, adLockreadonly, adCmdText
				'HowManyParentIDCount = 0 ' KitID Counter
				'HowManyParentIDCount = rsStockItemBelongToKitES.recordcount
				'do while HowManyParentIDCount > 0
				rw "<p>"
				'Add the hyperlink to Add a Stock Component to the kit in question by using the ParentID
				'if security(sClientAdmin) then
					'rw "<a href=""javascript:addtokit(" & rsStockItemBelongToKitES("ParentID") & ",'" & EditKitName & "','" &  false & "')"">Add a new component</a><p>"
				'end if
				
				
				'Add the hyperlink to Add a Stock Component to the kit in question by using the ParentID
				'if security(sClientAdmin) then
					'rw "<a href=""javascript:addtokit2('" & Join(KitIdArray, ",") & "','" & EditKitName & "','" &  false & "')"">Add a new component</a><p>"
				'end if
				
				'Add the hyperlink to Add a Stock Component to the kit in question by using the ParentID
				if security(sClientAdmin) then
					'wrap the Join in a Replace to remove extra commas like this
					rw "<a href=""javascript:addtokit2('" & Replace(Join(KitIdArray, ","),",,","") & "','" & EditKitName & "','" &  false & "')"">Add a new component</a><p>"
				end if
 
				'Add the hyperlink to Add a Stock Component to the kit in question by using the ParentID
				'if security(sClientAdmin) then
					'if there is a space between the commas use this
					'rw "<a href=""javascript:addtokit2('" & Replace(Join(KitIdArray, ","),", ,","") & "','" & EditKitName & "','" &  false & "')"">Add a new component</a><p>"
				'end if
 
		
				'loop
				'Add the Titles to each column
				rw "<table cellspacing=2 cellpadding=2 border=0>"
				rw "<tr valign=top>"
				rw "<td class=""bodytext"">&nbsp;</td>"
				rw "<td class=""tablehead"">Component Code</td>"
				rw "<td class=""tablehead"">Component Name</td>"
				rw "<td class=""tablehead"">Qty</td>"
				rw "<td class=""tablehead"">UnitCost</td>"
				rw "<td class=""tablehead"">Available</td>"
				rw "</tr>"
				kitnum = 0 ' array counter
				childCount = rsStockItemBelongToKitES.recordcount
				do while not rsStockItemBelongToKitES.eof
									
					if CurItemNum mod 2 = 1 then RowStyle = " style=""background-color:#F2F2F2;""" else RowStyle = ""
						rw "<tr valign=top" & RowStyle & ">"
						rw "<td class=""small"" width=10 style=""background-color:#ffffff;"">"
						
						if security(sClientAdmin)  then
							rw "<a href=""javascript:submitconfirm(" & rsStockItemBelongToKitES("ChildID") & "," & rsStockItemBelongToKitES("ParentID") & "," & childCount & ")""><img align=top src=""../img/trash16.gif"" border=0></a>"
						else
							rw "*"
						end if
					rw "</td>"
					rw "<td class=""small"">"
					if not rsStockItemBelongToKitES("dcode") = " " and security(sSuperUser) then
						if security(sClientAdmin) then
							rw "<a href=""/inv/edititemES.asp?id=" & rsStockItemBelongToKitES("ChildID") & "&stage=1"">"& rsStockItemBelongToKitES("Code") & "-" & rsStockItemBelongToKitES("Dcode") & "</a>&nbsp;</td>"
						else
							rw rsStockItemBelongToKitES("Code") & "-" & rsStockItemBelongToKitES("Dcode") & "&nbsp;</td>"
						end if
					else
						if security(sClientAdmin) then
							rw "<a href=""/inv/edititemES.asp?id=" & rsStockItemBelongToKitES("ChildID") & "&stage=1"">"& rsStockItemBelongToKitES("Code") & "</a>&nbsp;</td>"
						else
							rw rsStockItemBelongToKitES("Code") & "&nbsp;</td>"
						end if
					end if
					
					Available = UnCommittedStock(rsStockItemBelongToKitES("StockID")) 'uncommitted available in stock
					kitQty = rsStockItemBelongToKitES("qty")
					rw "<td class=""small"">" & rsStockItemBelongToKitES("StockName") & "&nbsp;</td>"
					if kitQty > Available then
						rw "<td class=""small"" style=""color: red;"" align=""right"">* &nbsp;<a href=""javascript:editkitqty(" & rsStockItemBelongToKitES("ParentID") & ", " & rsStockItemBelongToKitES("StockID") & ", " & KitQty & ", '" & KitName & "');"">" & kitQty & "</a>&nbsp;</td>"
						insufficientqty = true
					else
						rw "<td class=""small"" style=""color: green;"" align=""right""><a href=""javascript:editkitqty(" & rsStockItemBelongToKitES("ParentID") & ", " & rsStockItemBelongToKitES("StockID") & ", " & KitQty & ", '" & KitName & "');"">" & kitQty & "</a>&nbsp;</td>"
					end if
					rw "<td class=""small"" align=""right"">" & rsStockItemBelongToKitES("UnitCost") & "&nbsp;</td>"
					rw "<td class=""small"" align=""right"">" & Available & "&nbsp;</td>"
					maxkits = Available/KitQty
					kitArray(kitnum) = int(maxkits)
					pdebug kitArray(kitnum)
					kitnum = Kitnum + 1
					rw "</tr>"
					CurItemNum = CurItemNum + 1
					kitcost = kitQty * rsStockItemBelongToKitES("unitcost")
					totalCost = totalCost + kitcost
				 	rsStockItemBelongToKitES.movenext
				loop
				
								
				if kitArray(0) > 0 then
					rw "<p class=""bodytext""> Based on the current available stock a total of <span style=""color: green;""> <b>" & kitArray(0)  & "</b> </span> kits can be created."
				else
					rw "<p class=""bodytext"" style=""color: red;"" > At this time there is insufficient stock to create a kit."
				end if
				rw "<tr valign=top>"
					rw "<td class=""bodytext"" align=right>&nbsp;</td>"
					rw "<td class=""bodytext"" align=right>&nbsp;</td>"
					rw "<td class=""bodytext"" colspan=2><b>Total Kit Cost</b></td>"
					rw "<td class=""bodytext"" align=right>" & fnum(totalCost,2) & "</td>"
				rw "</tr>"
 
				rsnkitSummary.movenext
				
			loop
				if not insufficientqty then
					aSorted = fnSort(kitarray, 1)
					firstelement = false
					for index = lbound(aSorted) to ubound(aSorted)
						pdebug aSorted(index) & " "
						if not firstelement then
							if aSorted(index) > 0 then
								pdebug "lowest number" &  aSorted(index)
								firstelement = true
								kitArray(0) = asorted(index)
							end if
						end if
					next
 
				else
					kitArray(0) = 0
				end if
				'rw "<tr valign=top>"
					'rw "<td class=""bodytext"" align=right>&nbsp;</td>"
					'rw "<td class=""bodytext"" align=right>&nbsp;</td>"
					'rw "<td class=""bodytext"" colspan=2><b>Total Kit Cost</b></td>"
					'rw "<td class=""bodytext"" align=right>" & fnum(totalCost,2) & "</td>"
				'rw "</tr>"
				
			rw "</table>"
			
			rsStockItemBelongToKitES.close
			rsnkitSummary.close
 
			'rw "<p><a href=""kitssummaryES.asp"">&nbsp;Back</a>"
		end if
	end if
	dbconn.close
	set dbconn = nothing
end if
%>
 
<!--#include file="../inc/postproc.asp" -->
 
<!-- end main content -->
				</td>
			</tr>
		</table>
			<!--#include file="../inc/commonmenuscriptsfooter.asp" -->
 
	</body>
</html>
 
Second ASP Page:
<!--#include file="../inc/adovbs.asp" -->
<!--#include file="../inc/std.asp" -->
<!--#include file="../inc/const.asp" -->
 
<!--#include file="../inc/securitycheck.asp" -->
 
<html>
	<head>
	<title>
 
	</title>
	<link rel=stylesheet type="text/css" href="/inc/style.css">
	</head>
	<body class="bodytext">
 
<!-- main page content -->
 
<script language="JavaScript">
<!-- Hide
 
var ACProdArrAcc = new Array()
 
function ProdAcc(IDAcc, PNameAcc) {
	this.IDAcc		= IDAcc
	this.PNameAcc	= PNameAcc
}
 
<%
		stockID = request("stockID")
		set dbconn = Server.CreateObject("ADODB.Connection")
		dbconn.open ODBCsource
		set rsStockSub = Server.CreateObject("ADODB.Recordset")
		StockSQL = "SELECT Stock.StockID, Stock.Code, Stock.Dcode, Stock.StockName " & _
			"FROM Clients INNER JOIN Stock ON Clients.ClientID = Stock.ClientID " & _
			"WHERE (((Clients.ClientID)=" & ClientID & ") AND ((Stock.Deleted) Is Null)) " & _
			"ORDER BY StockName"
		
		
		rsStockSub.Open StockSQL, dbconn, adOpenKeyset, AdLockReadOnly, adCmdText
		
		if rsStockSub.eof then		' oops
			PError "An internal error occured."
		else
			while not rsStockSub.eof
			if security(sSuperUser) then
				SafeStockName = replace(rsStockSub("StockName") & "-" & rsStockSub("Dcode"), "'", "\'")
			else
				SafeStockName = replace(rsStockSub("StockName"), "'", "\'")
			end if
%>
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(<% = rsStockSub("StockID") %>,'<% = SafeStockName %>');
<%
				rsStockSub.movenext
			wend
		end if
%>
 
 
 
	var ResultsAcc;
	var HTMLAcc;
	function FindProductAcc(zoneAcc, event) {
 
		ResultsAcc = 0;
		HTMLAcc	= "";
 
		resultDivAcc = document.getElementById('resultAcc');
		resultTitleDivAcc = document.getElementById('resultTitleAcc');
		resultMessageDivAcc = document.getElementById('resultMessageAcc');
		resultListDivAcc = document.getElementById('resultListAcc');
		ACBAcc = document.searchAcc_form.searchAcc.value;
 
		for (i=0; i< ACProdArrAcc.length; i++) {
			if(ACBAcc.length > 0){
				var PName = ACProdArrAcc[i].PNameAcc.replace(/'/g, "\"'\"");
 
				if (PName.toLowerCase().substr(0, ACBAcc.length) == ACBAcc.toLowerCase() || PName.toLowerCase().indexOf(ACBAcc.toLowerCase()) > -1) {
					HTMLAcc = HTMLAcc + "<a href='javascript:ReturnSub(" + <% = stockID %> + ", " + ACProdArrAcc[i].IDAcc + ")' class='link'>" + PName + "</a><br>"
					ResultsAcc += 1;
				}
			}
		}
 
		if (ResultsAcc == 0){
			resultDivAcc.style.display = 'block';
			if (ACBAcc.length > 0) {
				resultMessageDivAcc.style.display = 'block';
			} else {
				resultMessageDivAcc.style.display = 'none';
			}
			resultTitleDivAcc.style.display = 'none';
			resultListDivAcc.style.display = 'none';
			resultListDivAcc.innerHTML = "";
			resultNum.style.display = 'none';
		}
		else{
			resultDivAcc.style.display = 'block';
			resultMessageDivAcc.style.display = 'none';
			resultTitleDivAcc.style.display = 'block';
			resultListDivAcc.style.display = 'block';
			resultListDivAcc.innerHTML = HTMLAcc;
			resultNum.style.display = 'block';
			resultNum.innerHTML = ResultsAcc + ' products found.<p>';
		}
	}
 
	function submitAccFinder() {
		if (ResultsAcc >= 1) {
			var index = HTMLAcc.indexOf("'");
			strLocation = HTMLAcc.substr(index+1, HTMLAcc.indexOf("'", index+1)-(index+1));
			document.location.href = strLocation;
		}
		return false;
	}
 
	function ReturnSub(stockID, ChildID) {
		var regexp = /^(\d+)$/;
 
		if (regexp.test(document.searchAcc_form.newqty.value)) {
			if (document.searchAcc_form.newqty.value < 1) {
 
				window.alert("Product's quantity must be atleast 1");
		         	}
 
			else {
 
				window.opener.location='addkitdetailES.asp?parentID=' + stockID + '&newchildid=' + ChildID + '&newqty=' + document.searchAcc_form.newqty.value + '&newkit=' + '<% = request("newflag") %>' + '&name=' + '<% = request("name") %>';
				window.opener.focus();
				self.close();
			     }
		}
		 else {
		window.alert("Quantity is either null or not a number");
	}
 
	}
-->
</script>
 
		<center><span class="bodyhead">Add a new component to <% = request("name") %></span><p>
<%
 
 
	stockID = request("stockID")
	Pdebug stockID
 
 
 
rw "<FORM id=searchAcc_form style=""MARGIN-BOTTOM: 0px"" " & _
	"name=searchAcc_form onsubmit=return(submitAccFinder()); " & _
	"action="""" method=get>"
   rw "<table border=0 cellspacing=0 cellpadding=2 width=""95%"">"
	rw "<tr>"
	rw "<TD vAlign=top width=100 class=""bodytext"">Enter Quantity: " & _
	"<input name=newqty size=5 style=""text-align:center;font-weight:bold;font-size:14px""></td><p>"
 
 
 
rw "<TD vAlign=top width=100 class=""bodytext"">"
	rw "<b>Product Name</b><br>"
	rw "<INPUT id=searchAcc onkeyup='FindProductAcc(""pp"", event)' " & _
		"style=""BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; " & _
		"BORDER-LEFT: black 1px solid; BORDER-BOTTOM: black 1px solid"" name=searchAcc>&nbsp;&nbsp;<p>"
		rw "<DIV id=resultNum style=""DISPLAY: none""></DIV>"
		rw "<a href=""javascript:window.close();"">Cancel</a>"
		rw "</TD>"
 
	rw "<td class=""bodytext"">"
 
	rw "<DIV id=resultAcc style=""DISPLAY: none"">"
	rw "<TABLE cellSpacing=0 cellPadding=0 border=0>"
	rw "<TR>"
	rw "<TD vAlign=top class=""bodytext"">"
	rw "<DIV id=resultTitleAcc "
	rw "style=""DISPLAY: none""><b>Matching products (Name)</b></DIV>"
	rw "<DIV id=resultListAcc "
	rw "style=""DISPLAY: none""></DIV>"
	rw "<DIV id=resultMessageAcc "
	rw "style=""DISPLAY: none"">Sorry, no matching products found.</DIV>"
 
	  rw "</td></tr>"
	rw "</table>"
	  rw "</td></tr>"
	rw "</table><p>"
	rw "</form>"
%>
 
<!-- end main content -->
	</center></body>
</html>
 
Third ASP Page (addkitdetailES.asp): Being called by the addKitproductES.asp
<!--#include file="../inc/adovbs.asp" -->
<!--#include file="../inc/std.asp" -->
<!--#include file="../inc/const.asp" -->
 
<!--#include file="../inc/securitycheck.asp" -->
<% if not (security(sWarehouseManager)) then response.redirect("/nosec.asp") %>
 
 
<html>
	<head>
		<title>
		<% rw BrandName %>
		</title>
<!--#include file="../inc/commonmenuscripts.asp" -->
 
<table width=<% = ScreenWidth %> border=0 cellpadding=0 cellspacing=0>
		<tr valign=top>
			<td width=<% = TableSpacing %>>
				&nbsp;
			</td>
 
 
			<td width=<% = TableWidth %> class="bodytext">
 
<!-- main page content -->
 
 
<%
	parentID = request("parentid")
	NewChildID = request("newchildid")
	newqty = request("newqty")
	kitname = request("name")
	' first check if record already exists or Can we return only unselected stocks???
 
 
 
	sqlstr = "INSERT INTO Kits ( ParentID, ChildID, Qty) " & _
		" VALUES (" & parentid & "," & NewChildID & "," & newqty & ")"
 
	Pdebug sqlstr & "<p>"
	set dbconn = Server.CreateObject("ADODB.Connection")
	dbconn.open ODBCsource
	dbconn.BeginTrans
	set rs = dbconn.Execute(sqlstr)
	retval = (CBool(dbconn.Errors.Count = 0)) 'returns true if no errors
	Pdebug "Retval= " & retval
	If retval = false then
		set rsAB = nothing
		logToFile "Error executing SQL statement"
		for ErrorCounter = 0 to dbconn.Errors.count -1
			logToFile dbconn.Errors(ErrorCounter).Description
		next
		PrintError "Error Found."
		dbconn.rollbacktrans
	else
		dbconn.committrans
	end if
	Audit ParentID, "ChildID " & NewChildID & " with qty " & newqty & " added to KitID " & ParentID ' log event
	dbconn.close
	set dbconn = Nothing
	response.redirect("viewkitdetailES.asp?id=" & parentid & "&name=" & kitname)
%>
 
<!-- end main content -->
				</td>
			</tr>
		</table>
	<!--#include file="../inc/commonmenuscriptsfooter.asp" -->
	</body>
</html>

Open in new window

0
 
darrylf290567Author Commented:
Hi thecodist,

wouldnt you need to break the stockid within the AddKitProductES.asp page where it does a request on the stockID:
stockID = request("stockID")
because at this point the three array values are here.
wouldnt i need to split it into an array here using your code? How do you do this? Im not sure how to do this? Can you please help me?

the code does not even reach the addkitdetailes.asp page because what it should be doing is as you type a letter into the Product Name text box within the AddKitProductES.asp page the stock items would display on the right hand side of the Product Name text box. It doesnt.

Can you please place the code necessary for these pages to work. It is much appreciated?


kind regards
darrylf290567
0
 
darrylf290567Author Commented:
Hi thecodist,

One more thing:
I put some javascripty debug alerts to see whether it was reaching the ReturnSub function in the AddKitProductES.asp page and it was not reaching to that function as shown below: look at my alert:
window.alert("msgbox 4: im in function ReturnSub");
function ReturnSub(stockID, ChildID) {
            var regexp = /^(\d+)$/;

            window.alert("msgbox 4: im in function ReturnSub");

            if (regexp.test(document.searchAcc_form.newqty.value)) {
                  if (document.searchAcc_form.newqty.value < 1) {

                        window.alert("Product's quantity must be atleast 1");
                           }

                  else {
                        //window.alert("msgbox 5: im in ReturnSub else statement");

                        window.opener.location='addkitdetailES.asp?parentID=' + stockID + '&newchildid=' + ChildID + '&newqty=' + document.searchAcc_form.newqty.value + '&newkit=' + '<% = request("newflag") %>' + '&name=' + '<% = request("name") %>';
                        window.opener.focus();
                        self.close();
                       }
            }
             else {
            window.alert("Quantity is either null or not a number");
      }

      }

I also put alert windows in the FindProdAcc function as shown below:
function FindProductAcc(zoneAcc, event) {

            ResultsAcc = 0;
            HTMLAcc      = "";
            
            //window.alert("msgbox 1: im in function FindProductAcc");

            resultDivAcc = document.getElementById('resultAcc');
            resultTitleDivAcc = document.getElementById('resultTitleAcc');
            resultMessageDivAcc = document.getElementById('resultMessageAcc');
            resultListDivAcc = document.getElementById('resultListAcc');
            ACBAcc = document.searchAcc_form.searchAcc.value;

            //window.alert("msgbox 2: im in function FindProductAcc");

            for (i=0; i< ACProdArrAcc.length; i++) {
                  if(ACBAcc.length > 0){
                        var PName = ACProdArrAcc[i].PNameAcc.replace(/'/g, "\"'\"");
                        
                        //window.alert("msgbox 3: im in function FindProductAcc");

                        //window.alert(PName);

                        if (PName.toLowerCase().substr(0, ACBAcc.length) == ACBAcc.toLowerCase() || PName.toLowerCase().indexOf(ACBAcc.toLowerCase()) > -1) {
                              HTMLAcc = HTMLAcc + "<a href='javascript:ReturnSub(" + <% = stockID %> + ", " + ACProdArrAcc[i].IDAcc + ")' class='link'>" + PName + "</a><br>"
                              ResultsAcc += 1;
                        }
                  }
            }

kind regards
darrylf290567
0
 
darrylf290567Author Commented:
Hi thecodist,

Where are you up to in the solution?

kind regards
darrylf290567
0
 
thecodistCommented:
darrylf290567,

Sorry, I have been away on a long 3-day weekend.

Regarding breaking the stockID you are right. That is why I suggested changing the name to stockIDs. I provided code for doing the split in a previous post (see 02.14.2008 at 08:22AM PST, ID: 20894643).

Now it sounds like we are on to a totally different problem, and I think you are on the right track placing Javascript debug alerts in various locations to determine program variable state. Unfortunately, from looking at the code for viewkitdetailES.asp I just can't figure out what it is trying to do. There are too many unknowns, like where is ClientID coming from? How do rsStockItemBelongToKitES and rsnkitSummary relate to each other? etc.

By the way, if you create yourself a small fuction, you can simplify a good deal of your code.

If Not IsInArray(KitIdArray, kitListID) Then
   KitIdArray(ArrayCounter) = kitListID
   ArrayCounter = ArrayCounter + 1
End If

Function IsInArray(ByVal aArray, ByVal oItem)
   Dim bIsInArray As Boolean
   bIsInArray = False
   Dim i
   For i = 0 To UBound(aArray)
      If aArray(i) = oItem Then
         bIsInArray = True
      End If
   Next
   IsInArray = bIsInArray
End Function

Thank you,
TheCodist
0
 
darrylf290567Author Commented:
hi thecodist,

are you going to look at the solution?

The problem is is not only in viewkitdetailES.asp  but also in AddKitProductES.asp where it calls the ReturnSub function.
see attached:
look at the addkitproductes.asp:
I tried placing the call to rw "<INPUT id=searchAcc onkeyup='FindProductAcc(""pp"", event) ' " & _  inside the For Next loop, because the FindProductAcc calls the ReturnSub. But that did not work.

kind regards
darrylf29056

<!--#include file="../inc/adovbs.asp" -->
<!--#include file="../inc/std.asp" -->
<!--#include file="../inc/const.asp" -->
 
<!--#include file="../inc/securitycheck.asp" -->
 
<html>
	<head>
	<title>
 
	</title>
	<link rel=stylesheet type="text/css" href="/inc/style.css">
	</head>
	<body class="bodytext">
 
<!-- main page content -->
 
<script language="JavaScript">
<!-- Hide
 
var ACProdArrAcc = new Array()
 
function ProdAcc(IDAcc, PNameAcc) {
	this.IDAcc		= IDAcc
	this.PNameAcc	= PNameAcc
}
 
<%
		stockID = request("stockID")
		set dbconn = Server.CreateObject("ADODB.Connection")
		dbconn.open ODBCsource
		set rsStockSub = Server.CreateObject("ADODB.Recordset")
		StockSQL = "SELECT Stock.StockID, Stock.Code, Stock.Dcode, Stock.StockName " & _
			"FROM Clients INNER JOIN Stock ON Clients.ClientID = Stock.ClientID " & _
			"WHERE (((Clients.ClientID)=" & ClientID & ") AND ((Stock.Deleted) Is Null)) " & _
			"ORDER BY StockName"
		
		
		rsStockSub.Open StockSQL, dbconn, adOpenKeyset, AdLockReadOnly, adCmdText
		
		if rsStockSub.eof then		' oops
			PError "An internal error occured."
		else
			while not rsStockSub.eof
			if security(sSuperUser) then
				SafeStockName = replace(rsStockSub("StockName") & "-" & rsStockSub("Dcode"), "'", "\'")
			else
				SafeStockName = replace(rsStockSub("StockName"), "'", "\'")
			end if
%>
				ACProdArrAcc[ACProdArrAcc.length] = new ProdAcc(<% = rsStockSub("StockID") %>,'<% = SafeStockName %>');
<%
				rsStockSub.movenext
			wend
		end if
%>
 
 
 
	var ResultsAcc;
	var HTMLAcc;
	function FindProductAcc(zoneAcc, event) {
 
		ResultsAcc = 0;
		HTMLAcc	= "";
 
		//window.alert(zoneAcc);
		//window.alert(event);
		
		//window.alert("msgbox 1: im in function FindProductAcc");
 
		resultDivAcc = document.getElementById('resultAcc');
		resultTitleDivAcc = document.getElementById('resultTitleAcc');
		resultMessageDivAcc = document.getElementById('resultMessageAcc');
		resultListDivAcc = document.getElementById('resultListAcc');
		ACBAcc = document.searchAcc_form.searchAcc.value;
 
		//window.alert("msgbox 2: im in function FindProductAcc");
 
		for (i=0; i< ACProdArrAcc.length; i++) {
			if(ACBAcc.length > 0){
				var PName = ACProdArrAcc[i].PNameAcc.replace(/'/g, "\"'\"");
				
				//window.alert("msgbox 3: im in function FindProductAcc");
 
				//window.alert(PName);
 
				if (PName.toLowerCase().substr(0, ACBAcc.length) == ACBAcc.toLowerCase() || PName.toLowerCase().indexOf(ACBAcc.toLowerCase()) > -1) {
					HTMLAcc = HTMLAcc + "<a href='javascript:ReturnSub(" + <% = stockIDs %> + ", " + ACProdArrAcc[i].IDAcc + ")' class='link'>" + PName + "</a><br>"
					ResultsAcc += 1;
				}
			}
		}
 
		if (ResultsAcc == 0){
			resultDivAcc.style.display = 'block';
			if (ACBAcc.length > 0) {
				resultMessageDivAcc.style.display = 'block';
			} else {
				resultMessageDivAcc.style.display = 'none';
			}
			resultTitleDivAcc.style.display = 'none';
			resultListDivAcc.style.display = 'none';
			resultListDivAcc.innerHTML = "";
			resultNum.style.display = 'none';
		}
		else{
			resultDivAcc.style.display = 'block';
			resultMessageDivAcc.style.display = 'none';
			resultTitleDivAcc.style.display = 'block';
			resultListDivAcc.style.display = 'block';
			resultListDivAcc.innerHTML = HTMLAcc;
			resultNum.style.display = 'block';
			resultNum.innerHTML = ResultsAcc + ' products found.<p>';
		}
	}
 
	function submitAccFinder() {
		if (ResultsAcc >= 1) {
			var index = HTMLAcc.indexOf("'");
			strLocation = HTMLAcc.substr(index+1, HTMLAcc.indexOf("'", index+1)-(index+1));
			document.location.href = strLocation;
		}
		return false;
	}
 
	function ReturnSub(pstockIDs, ChildID) {
		var regexp = /^(\d+)$/;
 
		window.alert("msgbox 4: im in function ReturnSub");
 
		if (regexp.test(document.searchAcc_form.newqty.value)) {
			if (document.searchAcc_form.newqty.value < 1) {
 
				window.alert("Product's quantity must be atleast 1");
		         	}
 
			else {
				//window.alert("msgbox 5: im in ReturnSub else statement");
 
				window.opener.location='addkitdetailES.asp?parentIDs=' + pstockIDs + '&newchildid=' + ChildID + '&newqty=' + document.searchAcc_form.newqty.value + '&newkit=' + '<% = request("newflag") %>' + '&name=' + '<% = request("name") %>';
				window.opener.focus();
				self.close();
			     }
		}
		 else {
		window.alert("Quantity is either null or not a number");
	}
 
	}
-->
</script>
 
		<center><span class="bodyhead">Add a new component to <% = request("name") %></span><p>
<%
 
 
	'stockID = request("stockID")
	'Pdebug stockID
 
	
 
aArray = Split(Request("stockID"), ",")
'Then you would loop through that array and process for each stockID:
Dim i
For i = 0 To UBound(aArray)
	stockIDs = aArray(i)
	Pdebug stockIDs
Next
 
 
 
rw "<FORM id=searchAcc_form style=""MARGIN-BOTTOM: 0px"" " & _
	"name=searchAcc_form onsubmit=return(submitAccFinder()); " & _
	"action="""" method=get>"
   rw "<table border=0 cellspacing=0 cellpadding=2 width=""95%"">"
	rw "<tr>"
	rw "<TD vAlign=top width=100 class=""bodytext"">Enter Quantity: " & _
	"<input name=newqty size=5 style=""text-align:center;font-weight:bold;font-size:14px""></td><p>"
 
 
 
rw "<TD vAlign=top width=100 class=""bodytext"">"
	rw "<b>Product Name</b><br>"
	rw "<INPUT id=searchAcc onkeyup='FindProductAcc(""pp"", event) ' " & _
		"style=""BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; " & _
		"BORDER-LEFT: black 1px solid; BORDER-BOTTOM: black 1px solid"" name=searchAcc>&nbsp;&nbsp;<p>"
		rw "<DIV id=resultNum style=""DISPLAY: none""></DIV>"
		rw "<a href=""javascript:window.close();"">Cancel</a>"
		rw "</TD>"
 
 
	rw "<td class=""bodytext"">"
 
	rw "<DIV id=resultAcc style=""DISPLAY: none"">"
	rw "<TABLE cellSpacing=0 cellPadding=0 border=0>"
	rw "<TR>"
	rw "<TD vAlign=top class=""bodytext"">"
	rw "<DIV id=resultTitleAcc "
	rw "style=""DISPLAY: none""><b>Matching products (Name)</b></DIV>"
	rw "<DIV id=resultListAcc "
	rw "style=""DISPLAY: none""></DIV>"
	rw "<DIV id=resultMessageAcc "
	rw "style=""DISPLAY: none"">Sorry, no matching products found.</DIV>"
 
	  rw "</td></tr>"
	rw "</table>"
	  rw "</td></tr>"
	rw "</table><p>"
	rw "</form>"
 
%>
 
<!-- end main content -->
	</center></body>
</html>

Open in new window

0
 
darrylf290567Author Commented:
Hi the codist,

I thought that if I place the call to the FindProductAcc function inside the For Next loop I could then pass multiple StockIDs but it does not work.


aArray = Split(Request("stockID"), ",")
'Then you would loop through that array and process for each stockID:
Dim i
For i = 0 To UBound(aArray)
	stockIDs = aArray(i)
	Pdebug stockIDs
 
 
 
 
rw "<FORM id=searchAcc_form style=""MARGIN-BOTTOM: 0px"" " & _
	"name=searchAcc_form onsubmit=return(submitAccFinder()); " & _
	"action="""" method=get>"
   rw "<table border=0 cellspacing=0 cellpadding=2 width=""95%"">"
	rw "<tr>"
	rw "<TD vAlign=top width=100 class=""bodytext"">Enter Quantity: " & _
	"<input name=newqty size=5 style=""text-align:center;font-weight:bold;font-size:14px""></td><p>"
 
 
 
rw "<TD vAlign=top width=100 class=""bodytext"">"
	rw "<b>Product Name</b><br>"
	rw "<INPUT id=searchAcc onkeyup='FindProductAcc(""pp"", event) ' " & _
		"style=""BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; " & _
		"BORDER-LEFT: black 1px solid; BORDER-BOTTOM: black 1px solid"" name=searchAcc>&nbsp;&nbsp;<p>"
		
		rw "<DIV id=resultNum style=""DISPLAY: none""></DIV>"
		rw "<a href=""javascript:window.close();"">Cancel</a>"
		rw "</TD>"
	Next

Open in new window

test1.GIF
0
 
thecodistCommented:
darrylf290567,

I have looked at the code but I still do not understand what it is trying to do. It is definitely something I don't have time to reverse engineer to understand. Did you write this original program or did you inherit it from someone else? I am wondering if this was originally written to work for just a single part number and you are trying to expand it to work for multiples. If you did not write it originally, is the original developer around to ask some questions to? Is there a requirements document that may shed some light on what the program is trying to do? Is there an ERD that shows the data relationships?

I also have my own complex problems to work on. I want to help as much as I can but do not have the time to delve into your code to understand all its in's and out's and figure out how to fix it for you. I have already answered the original question plus provided some additional suggestions as well. Maybe the current question should be awarded and closed and you should post a new question so you can get more eyes on it?

I'm sorry I haven't been more help.

TheCodist
0
 
darrylf290567Author Commented:
Hi thecodist,

I admit that you have answered the original question but I am only awarding the points of 300 and NOT the further 50 points. Do you agree so I can close it NOW?

regards
darrylf290567
0
All Courses

From novice to tech pro — start learning today.