Abnormal results with request.form and hidden fields
Abnormal results with request.form and hidden fields
am 17.10.2005 09:15:23 von Marc Llenas
Good morning, I'm encountering the following problem:
I have an ASP page with a form in which most of its values are loaded
from a recordset into hidden fields.
I have second ASP page used to process the parameters passed from the
first page (insert and update MS Access tables).
When requesting the hidden fields from the second page, request.form is
getting a string with all the values from the fisrt form instead of the
one being passed exclusively. For example, say the main page displays 10
records (in 10 different lines) and I want to update only one of them.
When I click on that particular record, I pass its ID on a hidden field
and the processing page receives the 10 ID's in the following format
1,2,3,4,5,6,7,8,9,10.
I have tried hardcoding the value of the hidden field to see if the
problem has something to do with assigning the values dinamically
looping through the recordset, then I get a result of
9,9,9,9,9,9,9,9,9,9.
*** Sent via Developersdex http://www.developersdex.com ***
Re: Abnormal results with request.form and hidden fields
am 17.10.2005 15:20:52 von unknown
Look at your HTML. You'll see that you have multiple inputs with the same
name, since you're writing them out in a loop. You have to give them unique
names if you want unique values.
Ray at work
"Marc Llenas" wrote in message
news:OpuaLqu0FHA.3892@TK2MSFTNGP12.phx.gbl...
> Good morning, I'm encountering the following problem:
>
> I have an ASP page with a form in which most of its values are loaded
> from a recordset into hidden fields.
>
> I have second ASP page used to process the parameters passed from the
> first page (insert and update MS Access tables).
>
> When requesting the hidden fields from the second page, request.form is
> getting a string with all the values from the fisrt form instead of the
> one being passed exclusively. For example, say the main page displays 10
> records (in 10 different lines) and I want to update only one of them.
> When I click on that particular record, I pass its ID on a hidden field
> and the processing page receives the 10 ID's in the following format
> 1,2,3,4,5,6,7,8,9,10.
>
> I have tried hardcoding the value of the hidden field to see if the
> problem has something to do with assigning the values dinamically
> looping through the recordset, then I get a result of
> 9,9,9,9,9,9,9,9,9,9.
>
> A snippet of the calling page is:
A TRUE SNIPPET:
> Do While objRst2.EOF = False
> If objRst("UseID") = objRst2("PenUserID") Then
> %>
>
Re: Abnormal results with request.form and hidden fields
am 18.10.2005 12:08:52 von mmcginty
"Marc Llenas" wrote in message
news:OpuaLqu0FHA.3892@TK2MSFTNGP12.phx.gbl...
> Good morning, I'm encountering the following problem:
>
> I have an ASP page with a form in which most of its values are loaded
> from a recordset into hidden fields.
>
> I have second ASP page used to process the parameters passed from the
> first page (insert and update MS Access tables).
>
> When requesting the hidden fields from the second page, request.form is
> getting a string with all the values from the fisrt form instead of the
> one being passed exclusively. For example, say the main page displays 10
> records (in 10 different lines) and I want to update only one of them.
> When I click on that particular record, I pass its ID on a hidden field
> and the processing page receives the 10 ID's in the following format
> 1,2,3,4,5,6,7,8,9,10.
>
> I have tried hardcoding the value of the hidden field to see if the
> problem has something to do with assigning the values dinamically
> looping through the recordset, then I get a result of
> 9,9,9,9,9,9,9,9,9,9.
That's a normal result given that you have multiple inputs with the same
name in the same form.
The easiest way in terms of coding the called page is to generate a separate
html form tag for each record, that way the inputs' names can be the same,
while only the values from one row will be posted.
-Mark
> A snippet of the calling page is:
>
> *****************************************************
>
> *****************************************************
>
> The function that submits is:
> *****************************************************
>
> *****************************************************
>
> The page requesting the fields is (in debbuging mode):
> *****************************************************
>
> <%
> Dim intPenID
> Dim intQty
> Dim intUserID
> Dim strReqDate
> Dim intDay
> Dim intMonth
> Dim intYear
> Dim intReqType
> Dim intType
>
> intPenID = request.form("hidPenID")
>
> response.write intPenID
> 'Check if there is any matches for the user and date and type 1 or 6
> '----------------------------------------------------------- ---
> Dim objConn
> Dim objRst
> Set objConn = GetConnection()
> strsql = "UPDATE TblPending SET TblPending.PenProcessed = True,
> TblPending.PenProcessedDate = #" & Now() & "# WHERE
> (((TblPending.PenID)=" & intPenID & "));"
> 'response.write strSQL
> ' Set objRst = objConn.Execute(strSQL,129)
> '----------------------------------------------------------- ---
> intQty = 0
> intUserID = request.form("hidUserID")
> strReqDate = request.form("hidDate")
> ' intDay = Day(strReqDate)
> ' intMonth = Month(strReqDate)
> ' intYear = Year(strReqDate)
> intReqType = request.form("hidTypeReq")
> ' Select Case intReqType
> ' Case 11 'Pendent dia de vacances
> ' intType = 1
> ' intQty = "1"
> ' Case 12 'Pendent mig dia de vacances
> ' intType = 6
> ' intQty = "0,5"
> ' Case 13 'Pendent dia de permis
> ' intType = 7
> ' intQty = "1"
> ' Case 14 'Pendent mig dia de permis
> ' intType = 8
> ' intQty = "0,5"
> ' End Select
> '----------------------------------------------------------- ---
> strsql = "UPDATE TblMain SET TblMain.MaiQty = '" & intQty & "',
> TblMain.MaiType = " & intType & ", TblMain.MaiTypeRequested = Null WHERE
> (((TblMain.MaiUserID)=" & intUserID & ") AND ((TblMain.MaiDay)=" &
> intDay & ") AND ((TblMain.MaiMonth)=" & intMonth & ") AND
> ((TblMain.MaiYear)=" & intYear & ") AND ((TblMain.MaiType)=11 Or
> (TblMain.MaiType)=12 Or (TblMain.MaiType)=13 Or (TblMain.MaiType)=14));"
> ' Set objRst = objConn.Execute(strSQL,129)
> '----------------------------------------------------------- ---
> '----------------------------------------------------------- ---
> Set objConn = Nothing
> '----------------------------------------------------------- ---
>
> ' Response.Redirect "admin.asp"
>
> %>
> *****************************************************
>
> Any idea why I could be getting this error?
>
> Cheers,
>
> Marc
>
> *** Sent via Developersdex http://www.developersdex.com ***