开发者

ASP MySQL Loop Array

I have a page which builds the following form through Ajax.

<form action="go.asp" method="get">
    <!--row-->
    <input type='hidden' name='BundleItemID' id='BundleItemID' value='123'/>
    <input type='hidden' name='BundleColorID' id='BundleColorID' value='4'/>
    <input type='hidden' name='BundleSizeID' id='BundleSizeID' value='Large'/>
    <input type='hidden' name='BundleQtyID' id='Bund开发者_如何学GoleQtyID' value='4'/>
    <!--#row-->
</form>

The form builds up and loops between the row, so data will look like:

<form action="go.asp" method="get">
    <!--row-->
    <input type='hidden' name='BundleItemID' id='BundleItemID' value='123'/>
    <input type='hidden' name='BundleColorID' id='BundleColorID' value='4'/>
    <input type='hidden' name='BundleSizeID' id='BundleSizeID' value='Large'/>
    <input type='hidden' name='BundleQtyID' id='BundleQtyID' value='4'/>
    <!--#row-->
    <!--row-->
    <input type='hidden' name='BundleItemID' id='BundleItemID' value='123'/>
    <input type='hidden' name='BundleColorID' id='BundleColorID' value='4'/>
    <input type='hidden' name='BundleSizeID' id='BundleSizeID' value='Large'/>
    <input type='hidden' name='BundleQtyID' id='BundleQtyID' value='4'/>
    <!--#row-->
    <!--row-->
    <input type='hidden' name='BundleItemID' id='BundleItemID' value='123'/>
    <input type='hidden' name='BundleColorID' id='BundleColorID' value='4'/>
    <input type='hidden' name='BundleSizeID' id='BundleSizeID' value='Large'/>
    <input type='hidden' name='BundleQtyID' id='BundleQtyID' value='4'/>
    <!--#row-->
    <!--row-->
    <input type='hidden' name='BundleItemID' id='BundleItemID' value='123'/>
    <input type='hidden' name='BundleColorID' id='BundleColorID' value='4'/>
    <input type='hidden' name='BundleSizeID' id='BundleSizeID' value='Large'/>
    <input type='hidden' name='BundleQtyID' id='BundleQtyID' value='4'/>
    <!--#row-->
</form>

I want to submit a form to go.asp - this page will loop through everything between row and submit the data into mySQL, my code so far:

<%
    dim LoopData

        for i=1 to Request.QueryString("BundleItemID").Count

            Set rs = Server.CreateObject("ADODB.Recordset")
            sql = "SELECT * FROM tblProducts"
            rs.Open sql, conn.c
            While Not rs.EOF

        LoopData = LoopData & Request.QueryString("BundleItemID")(i) & ""

        sql= "INSERT INTO tblProducts (BundleItemID,BundleColorID,BundleSizeID,BundleQtyID) VALUES ("&request("BundleItemID")&","&request("BundleColorID")&","&request("BundleSizeID")&","&request("BundleQtyID")&")"

        rs.MoveNext()
        Wend


    next

%>

How would I do this please?


i've resolved this problem for a "Simple Way":

what i did was create an array of objects(in JSON) an sent to the server (via post).

the array looks like this:

var arr = [{"ItemID":123,"ColorID":4, "SizeID":"Large", "QtyID"4"},
    {"ItemID":123,"ColorID":4, "SizeID":"Large", "QtyID"4"},
    {"ItemID":123,"ColorID":4, "SizeID":"Large", "QtyID"4"},
    {"ItemID":123,"ColorID":4, "SizeID":"Large", "QtyID"4"}]

After that, go to the page that receives this data and analyse the names generated for the Request, you will find a numeric sequencial var names.

that you only have to call the correct name on for statement some thing like this:

for i =0 to 4

Dim strName = "arr[" & i & "]ItemID"
Dim strValue = request(strName)

next

you can send a variable with the array Length to help you on your for atatement

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜