Print request.form values

Asked

Viewed 112 times

1

I have the following code below, and by clicking on the record button run the first two Replays. But they are printing empty fields. What’s wrong with my code?

CODE:

<%
    Dim year_, lista(), cList, x, vHol()
    year_=year(date())

    response.write request.form("lista(0,1)")
    response.write request.form("valor_1")

    call LoadUsers()
%>

<form action="layOff.asp?sid=<%=sid%>&opc=sav" method="POST" name="form" style="margin-top:0;">
    <table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr>
            <td class=Font9Bold><br><%=msg("90130", lng)%></td>
        </tr>
        <tr height="25" bgcolor="#efefef">
            <td colspan=3 style="border-color:'navy';border-style:solid;border-top-width:1px;border-bottom-width:1px;border-right-width:0px;border-left-width:0px;">
            &nbsp;<input class=Button type="submit" name="submit" value=" <%=msg("50001", lng)%> ">
            &nbsp;<input class=Button type="Button" name="Submit" value=" <%=msg("50002", lng)%> " OnClick="location.href='../mnt/manut.asp?sid=<%=sid%>'">
            </td>
        </tr>
        <tr height="30">
            <td><br/></td>
        </tr>
        <tr>
            <td class=Font9Red colspan=2>
                <%=sMsg%>
            </td>
        </tr>
     </table>

    <table width="500" border="0" cellspacing="0" cellpadding="0" align="center">
      <tr height="25" bgcolor="#efefef" class=Font10Bold>
        <td width="50" style="border-color:'navy';border-style:solid;border-top-width:1px;border-bottom-width:1px;border-right-width:0px;border-left-width:0px;">
            <%=msg("90002", lng)%>
        </td>
        <td width="400" style="border-color:'navy';border-style:solid;border-top-width:1px;border-bottom-width:1px;border-right-width:0px;border-left-width:0px;">
            <%=msg("90033", lng)%>
        </td>
        <td align="center" width="60" style="border-color:'navy';border-style:solid;border-top-width:1px;border-bottom-width:1px;border-right-width:0px;border-left-width:0px;">
            <%=msg("90130", lng) & " " & year_%> 
        </td>
      </tr>
      <% FOR x=0 to cList-1%>
      <tr class='Font10'>
          <td><%=lista(x,1)%></td>
          <td><%=lista(x,2)%></td>
          <td align="center"><input class=NumberBox type="text" name="valor_<%=x%>" value="<%=ValueHol(lista(x,0))%>" size="3" maxlength="2"></td>
      </tr>
      <%NEXT%>
    </table>
    <br/><br/><br/><br/>
</form>

<%
    Function LoadUsers()
        Dim y, i

        sSQL="SELECT tbUsers.uid, tbUsers.user_, tbUsers.name "
        sSQL=sSQL & "FROM tbUsers "
        sSQL=sSQL & "WHERE user_<>'ADMIN' "
        sSQL=sSQL & " ORDER BY name"
        Set RS = MyConn.Execute(sSQL)

        cList=0
        while not rs.EOF
            cList=cList+1
            rs.MoveNext
        wend
        Set RS = MyConn.Execute(sSQL)

        redim lista(cList,2)

        i=0
        while not rs.EOF
            lista(i,0)=rs("uid")
            lista(i,1)=rs("user_")
            lista(i,2)=rs("name")
            i=i+1
            rs.MoveNext
        wend
    End Function

    Function ValueHol(uid)
        sSQL="SELECT days_year "
        sSQL=sSQL & "FROM tbLayOffTop "
        sSQL=sSQL & "WHERE uid='" & uid & "'"
        Set RS = MyConn.Execute(sSQL)

        if not rs.eof then
            ValueHol=rs("days_year")
        end if      
    End Function

    Sub save()
        For i=0 to cList-1
            sSQL="DELETE * FROM tbLayOff WHERE year_='" & year_ & "' AND month_='" & i & "' AND uid=" & lista(i,0)
            Set RS = MyConn.Execute(sSQL)

            sSQL="INSERT INTO tbLayOff (year_, uid, days_year"
            sSQL2="insert_by, insert_date) "
            sSQL3="VALUES ('" & year_ & "', '" & lista(i,0) & "', " &  document.all("valor_" + cstr(i)).value & "', "

            sSQL=sSQL & sSQL2 & sSQL3 & "'" & uid & "', " & "'" & date_now & "')"
            response.write sSQL
        Next    
    End Sub
%>
  • 1

    Do you do a POST to a page also by sending a Querystring? Isn’t there something wrong there? Transfer the querystring sid=<%=sid%>&opc=sav for two Hiddens inside your form and try again.

1 answer

0

your form is set to "post" and in addition the action contains information "GET".

To receive data via POST in Asp is used request.form("campo") To receive data via GET on Asp is used request.QueryString("campo")

To receive both POST or GET, type only request("campo")

response.write request("lista(0,1)")
response.write request("valor_1")
response.write request("sid")
response.write request("opc")

Browser other questions tagged

You are not signed in. Login or sign up in order to post.