I have a system within my html holiday booking app which prints out an array of holiday requests which look like so.
For i = 0 To Ubound(arrHolsAccept) Step 1
response.Write("<form action=""AdminGUI.asp"" method=""post"">")
Response.write("<tr>")
Response.write("<td>"& "<input type=""hidden"" name=""HolidayID"" value=" &arrHolsAccept(i,0)& " " & "</td>")
Response.write("<td>"& arrHolsAccept(i,1) &"</td>")
Response.write("<td>"& arrHolsAccept(i,2) &"</td>")
Response.write("<td>"& arrHolsAccept(i,3) &"</td>")
Response.write("<td>"& arrHolsAccept(i,4) &"</td>")
Response.write("<td><input type=""submit"" name=""accepthol"" value=""Accept""/><td/>")
Response.write("<td><input type=""submit"" name=""declinehol"" value=""Decline""/><td/>")
Response.write("</tr>")
response.write("<form/>")
Next
the Issue I am having is that the accept and decline buttons within each array item set that is printed out need to pass a value to the database. which is the holiday ID arrHolsAccept(i,0)
how can I get these submit and decline buttons to pass this value to the database connection element?
so far my connection element of the system looks as follows
objDBCommand.Parameters.Append objDBCommand.CreateParameter("@HolidayRef", adVarChar, adParamInput,200)
objDBCommand.Parameters.Append objDBCommand.CreateParameter("@EmployeeID", adVarChar, adParamInput,200)
objDBCommand.Parameters.Append objDBCommand.CreateParameter("@jobroleofstaff", adVarChar, adParamInput,200)
objDBCommand("@HolidayRef") = Request.Form("HolidayID")
objDBCommand("@EmployeeID") = Session("userID")
objDBCommand("@jobroleofstaff") = Session("JobroleID")
the submit and decline buttons run this section of code and are supposed to pass it a value. as the array builds the holidays it builds multiple of these submit and decline buttons and I do not know how to differentiate the buttons and then assign the correct holiday ID to them, I have tried multiple things so far and I can't seem to get it to work.
You are already passing the HolidayID / arrHolsAccept(i,0) as a hidden field on this line:
Response.write("<td>"& "<input type=""hidden"" name=""HolidayID"" value=" &arrHolsAccept(i,0)& " " & "</td>")
And you are passing that value to the database stored procedure on this line already:
objDBCommand("@HolidayRef") = Request.Form("HolidayID")
I think the problem you are having is possibly because you are not closing your form. You have an error in your code and need to change this line:
response.write("<form/>")
To:
response.write("</form>")