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.

A snippet of the calling page is:

*****************************************************


cellpadding="0">









<%
'----------------------------------------------------------- ---
Set objConn = GetConnection()
strSQL = "SELECT TblUsers.UseID, [TblUsers]![UseFirst] & ' ' &
[TblUsers]![UseLast] AS FullUser FROM TblUsers INNER JOIN TblPending ON
TblUsers.UseID = TblPending.PenUserID GROUP BY TblUsers.UseID,
[TblUsers]![UseFirst] & ' ' & [TblUsers]![UseLast] ORDER BY
[TblUsers]![UseFirst] & ' ' & [TblUsers]![UseLast];"

Set objRst = objConn.Execute(strSQL,1)
'----------------------------------------------------------- ---
Do While objRst.EOF = False
%>




<%
'----------------------------------------------------------- ---
Dim objConn2
Dim objRst2
Set objConn2 = GetConnection()
strSQL = "SELECT TblPending.PenUserID, CDate([TblPending]![PenDay] &
'-' & [TblPending]![PenMonth] & '-' & [TblPending]![PeniYear]) AS
FullDate, TblType.TypName, TblPending.PenReason, TblPending.PenDateReq,
TblPending.PenType, TblPending.PenID FROM TblType INNER JOIN TblPending
ON TblType.TypID = TblPending.PenType WHERE
(((TblPending.PenProcessed)=False)) ORDER BY CDate([TblPending]![PenDay]
& '-' & [TblPending]![PenMonth] & '-' & [TblPending]![PeniYear]);"
Set objRst2 = objConn2.Execute(strSQL,1)
'----------------------------------------------------------- ---
Do While objRst2.EOF = False
If objRst("UseID") = objRst2("PenUserID") Then
%>








<%
End If
objRst2.MoveNext
Loop
%>

<%
objRst.MoveNext
Loop
'----------------------------------------------------------- ---
Set objConn = Nothing
'----------------------------------------------------------- ---

%>
class="HeaderTitle"> class="HeaderTitle"> align="left">Data sol.licitada class="HeaderTitle"> align="left">Sol.licitud pendent align="left">Motiu align="left">Data sol.licitud
class="HeaderTitle"><%= objRst("FullUser") %>

"
name="hidPenID">
">
">
">
src="images/requestaccept.gif" alt="<% response.write objRst2("PenID")
%>" onclick="return OnButton1();">
src="images/requestdeny.gif" alt="Denegar sol.licitud" onclick="return
OnButton2();">
<%=
IsoDate(obJrst2("FullDate")) %>

<%
Select Case objRst2("PenType")
Case 11 'Pendent dia de vacances
%> height="16" alt="<%= objRst2("TypName") %>"><%
Case 12 'Pendent mig dia de vacances
%> height="16" alt="<%= objRst2("TypName") %>"><%
Case 13 'Pendent dia de permis
%> height="16" alt="<%= objRst2("TypName") %>"><%
Case 14 'Pendent mig dia de permis
%> height="16" alt="<%= objRst2("TypName") %>"><%
Case Else
%> height="16" alt="<%= objRst2("TypName") %>"><%
End Select
%>
<%=
obJrst2("TypName") %>
<%=
obJrst2("PenReason") %>
<%=
IsoDate(obJrst2("PenDateReq")) %>


*****************************************************

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 ***

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
> %>
>
>
> "
> name="hidPenID">
> ">
> ">
> ">
> > src="images/requestaccept.gif" alt="<% response.write objRst2("PenID")
> %>" onclick="return OnButton1();">
>
> > src="images/requestdeny.gif" alt="Denegar sol.licitud" onclick="return
> OnButton2();">
> <%=
> IsoDate(obJrst2("FullDate")) %>

>> End If
> objRst2.MoveNext
> Loop
>

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:
>
> *****************************************************
>


> > cellpadding="0">
>
>
>
>
>
>
>
>
>
> <%
> '----------------------------------------------------------- ---
> Set objConn = GetConnection()
> strSQL = "SELECT TblUsers.UseID, [TblUsers]![UseFirst] & ' ' &
> [TblUsers]![UseLast] AS FullUser FROM TblUsers INNER JOIN TblPending ON
> TblUsers.UseID = TblPending.PenUserID GROUP BY TblUsers.UseID,
> [TblUsers]![UseFirst] & ' ' & [TblUsers]![UseLast] ORDER BY
> [TblUsers]![UseFirst] & ' ' & [TblUsers]![UseLast];"
>
> Set objRst = objConn.Execute(strSQL,1)
> '----------------------------------------------------------- ---
> Do While objRst.EOF = False
> %>
>
>
>
>
> <%
> '----------------------------------------------------------- ---
> Dim objConn2
> Dim objRst2
> Set objConn2 = GetConnection()
> strSQL = "SELECT TblPending.PenUserID, CDate([TblPending]![PenDay] &
> '-' & [TblPending]![PenMonth] & '-' & [TblPending]![PeniYear]) AS
> FullDate, TblType.TypName, TblPending.PenReason, TblPending.PenDateReq,
> TblPending.PenType, TblPending.PenID FROM TblType INNER JOIN TblPending
> ON TblType.TypID = TblPending.PenType WHERE
> (((TblPending.PenProcessed)=False)) ORDER BY CDate([TblPending]![PenDay]
> & '-' & [TblPending]![PenMonth] & '-' & [TblPending]![PeniYear]);"
> Set objRst2 = objConn2.Execute(strSQL,1)
> '----------------------------------------------------------- ---
> Do While objRst2.EOF = False
> If objRst("UseID") = objRst2("PenUserID") Then
> %>
>
>
>
>
>
>
>
>
> <%
> End If
> objRst2.MoveNext
> Loop
> %>
>
> <%
> objRst.MoveNext
> Loop
> '----------------------------------------------------------- ---
> Set objConn = Nothing
> '----------------------------------------------------------- ---
>
> %>
>
> class="HeaderTitle"> > class="HeaderTitle"> > align="left">Data sol.licitada > class="HeaderTitle"> > align="left">Sol.licitud pendent > align="left">Motiu > align="left">Data sol.licitud
> class="HeaderTitle"><%= objRst("FullUser") %>

> "
> name="hidPenID">
> ">
> ">
> ">
> > src="images/requestaccept.gif" alt="<% response.write objRst2("PenID")
> %>" onclick="return OnButton1();">
>
> src="images/requestdeny.gif" alt="Denegar sol.licitud" onclick="return
> OnButton2();">
<%=
> IsoDate(obJrst2("FullDate")) %>

> <%
> Select Case objRst2("PenType")
> Case 11 'Pendent dia de vacances
> %> > height="16" alt="<%= objRst2("TypName") %>"><%
> Case 12 'Pendent mig dia de vacances
> %> > height="16" alt="<%= objRst2("TypName") %>"><%
> Case 13 'Pendent dia de permis
> %> > height="16" alt="<%= objRst2("TypName") %>"><%
> Case 14 'Pendent mig dia de permis
> %> > height="16" alt="<%= objRst2("TypName") %>"><%
> Case Else
> %> > height="16" alt="<%= objRst2("TypName") %>"><%
> End Select
> %>
<%=
> obJrst2("TypName") %>
<%=
> obJrst2("PenReason") %>
<%=
> IsoDate(obJrst2("PenDateReq")) %>
>

>

> *****************************************************
>
> 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 ***