ASP,HTML输入我需要返回一个与另一个字段无关的值

时间:2022-02-22 11:49:29

I have a system within my html holiday booking app which prints out an array of holiday requests which look like so.

我的html假日预订应用程序中有一个系统,它打印出一系列假日请求,看起来像这样。

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?

我遇到的问题是打印出的每个数组项集中的接受和拒绝按钮需要将值传递给数据库。这是假日ID arrHolsAccept(i,0)如何获取这些提交和拒绝按钮以将此值传递给数据库连接元素?

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.

提交和拒绝按钮运行此代码段,并且应该传递一个值。当数组构建假期时,它构建了多个这些提交和拒绝按钮,我不知道如何区分按钮,然后为它们分配正确的假日ID,我到目前为止尝试了多项内容,我似乎无法获得它工作。

2 个解决方案

#1


1  

You are already passing the HolidayID / arrHolsAccept(i,0) as a hidden field on this line:

您已经将HolidayID / arrHolsAccept(i,0)作为此行上的隐藏字段传递:

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>")

#2


0  

Put the values of arrHolsAccept(i,1) as the value in a hidden field, comma-separated, then parse it on the server after the form is submitted.

将arrHolsAccept(i,1)的值作为隐藏字段中的值,以逗号分隔,然后在提交表单后在服务器上解析它。

#1


1  

You are already passing the HolidayID / arrHolsAccept(i,0) as a hidden field on this line:

您已经将HolidayID / arrHolsAccept(i,0)作为此行上的隐藏字段传递:

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>")

#2


0  

Put the values of arrHolsAccept(i,1) as the value in a hidden field, comma-separated, then parse it on the server after the form is submitted.

将arrHolsAccept(i,1)的值作为隐藏字段中的值,以逗号分隔,然后在提交表单后在服务器上解析它。