Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 20th, 2004, 10:11 AM
Registered User
 
Join Date: Aug 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to el_oliver
Default POST Variables not sent.

Greetings.

I'm working with a dynamic page using ASP, but the input textboxes doesn't transfer when I post the form. I build the textboxes dynamically, when I get the initial values for them. But when I submit the form, it goes to the page I need, but there are no elements in the Request.Form collection.
If I use the GET method, the variables go without problem. But I prefer using the POST method, so users can't pass parameters just by typing them at the address bar.
Before I post the code, I want to give you many thanks in advance.

Here's the ASP code. Besides, most of the variable names are in spanish. The data is stored in an bidimensional array:



sub mostrarArrPant ()
dim i
dim mes

    for i = 0 to 11
        mes = i + 1
        call imprHTML ("<tr>")
        call imprHTML ("<td width='100' align='right'><strong>" & nombreMes (mes) & ":</strong></td>")
        call imprCeldaCampo (mes, "Most", arrPresupMontos(0, i))
        call imprCeldaCampo (mes, "Tall", arrPresupMontos(1, i))
        call imprCeldaCampo (mes, "VMSC", arrPresupMontos(2, i))
        call imprHTML ("</tr>")
    next
end sub

sub imprCeldaCampo (intMes, strTipo, sngValor)
dim strCampo
dim strMes
    if intMes < 10 then
        strMes = "0"
    else
        strMes = ""
    end if
    strMes = strMes & CStr (intMes)
    strCampo = "txt" & strMes & strTipo
    call imprHTML ("<td align='center' width='120'>")
    call imprHTML ("<input name='" & strCampo & "' id='" & strCampo & "' type='text' value='" & _
                 formatNumber (sngValor, 2) & "' size='15' maxlength='15'class='alinearDerecha'>")
    call imprHTML ("</td>")
end sub



It works fine, and it creates the 36 textboxes. Here is the form definition:

<form action="grabarPresupCliente.asp" method="post" enctype="multipart/form-data" name="frmMtosClte" target="_self" onSubmit="return validarMontos(this)">

It calls a JavaScript function to validate the contents of the fields.

Once again, many thanks for your help.

Oliver.
 
Old August 20th, 2004, 10:28 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Can you also post the code that you used to capture data from request.form collection? That should give better idea.

_________________________
- Vijay G
Strive for Perfection
 
Old August 20th, 2004, 01:56 PM
Registered User
 
Join Date: Aug 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to el_oliver
Default

   Greetings...

   Sure, I can post the code I use to get the variables. Here it is:



sub cargarArrPresup ()
dim strElem
dim intMes
dim strCampo
dim intPosic
    for each strElem in request.form
        if LCase (Left (strElem, 3)) = "txt" then
            intMes = CInt (Mid (strElem, 4, 2)) - 1
            intPosic = obtPosicTipoVta (Right (strElem, 4))
            arrPresupMontos(intPosic, intMes) = CSng (server.HTMLEncode(request.form(strElem)))
        end if
    next
end sub



   If I use the GET method before and the "request.queryString" instead of POST and "request.form" it works. But, as I said before, I prefer to use the POST method.

   Many thanks for your quick answer.

Oliver
 
Old August 21st, 2004, 05:53 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Here is a simple example. It works fine with post/get. Copy paste the entire code into an asp file and check this out.

Try this code, if things are fine, comment the lines in BLUE and then uncomment the lines in GREEN below and try that too. Both works perfect. That should give you some idea.
Code:
<%
    If Request.Form("submit") = "submit" Then
        for i=0 to 10
        ' for each strElem in request.form
            Response.Write Request.Form("txt" & i) & "<BR>"
            ' Response.Write Request.Form(strElem) & "<BR>"
        next
    End If
%>

<html>
<head>
</head>
<body>
    <form name="frm1" action="" method="post">
        <%
            for i=0 to 10
                Response.write "<input type='text' name='txt" & i & "' value='" & "txt " & i & "'><BR>"
                ' Response.write "<input type='text' name='txt" & i & "' value=''><BR>"
            next
        %>
        <input type="submit" name="submit" value="submit">
    </form>
</body>
</html>
Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
I was not sure where to post this iceman90289 C# 2005 1 March 26th, 2008 03:19 AM
GET and POST vinoskiboyetski Pro PHP 1 October 8th, 2007 10:28 AM
Passing Post Variables susb8383 PHP How-To 3 April 1st, 2007 02:07 PM
"Where do I post this?" Snib Forum and Wrox.com Feedback 0 March 15th, 2004 05:01 PM
Post Method? zhenwe1 Servlets 0 January 25th, 2004 01:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.