I'm having some trouble with an array. I'm have three list which I'm trying to insert into a database:
Here is an example of what the list would look like:
IngredientID List: 8,8
QuantityID List: 64,64
MeasurementID List: 60,60
As you see, I have three stes of values which I have successfully taken the ingredienIDs, the quantityIDs, and the MeasurementIDs from a drop list and put them in a hidden form. So I have three hidden forms: a form that contains the list of ingredientIDs, one for the list quantityIDs and one for the list of measurementIDs. The list of the ids vary depending on how many ingredients you choose to add to the recipe so if the recipe has 10 ingredients, you would select ten from the first drop down, and then the page would reload to show ten rows of three sets of drop downs. The drop downs are the ingredients (which I take the value ingredientID), the quantity of the ingredient (which I get the quantityID), and the measurement of the ingredient (which I get the measurementID from). The values all go into the hidden forms I mentioned above.
With me so far? I hope so!
So the first page is fine, I think. All I want from that page is the correct list of the IDs and I've got that.
So when you hit submit, it goes to a page I call process.asp and it is supposed to enter the list of IDs into the database at one time. Specifically, if the recipe had ten ingredients, it's supposed to enter 10 rows into the table: one row for each ingredient, and three values: the measurementID, the ingredientID, and the quantityID.
Here is my code for the process.asp page:
<%@LANGUAGE="VBSCRIPT"%> <!--#include file="Connections/ConnStudioApp.asp" --> <% If Request.Form("submit") = "CONTINUE" Then 'read the list of questions listOfIngredients = Split(Request.Form("ingredientIds"), ",") listOfQuantities = Split(Request.Form("quantities"), ",") For i = 0 to UBound(listOfQuantities) quantity = Request.Form("q_" & listOfQuantities(i)) 'For i = 0 to Ubound(listofQuantities) 'quantity = Request.Form("q_" & listOfQuantities(i)) author = request.form("author") measurement = 9 'quantity = 4 ingredients = 5 response.write quantity & "<br>" 'insert question id and answer into the database insertStmt = "INSERT INTO ingredients_recipes (ingredients, measurement, quantity) values (" & ingredients & "," & measurement & "," & quantity & ");" 'objConn.Execute insertStmt 'Next Next End If 'Response.Redirect("add_recipe.asp?code=5") %>
what am I doing wrong? Please help!!!