how to use Request.Form("fieldname")?

Discussion in 'ASP General' started by Rich, Mar 23, 2006.

  1. Rich

    Rich Guest

    Hi,

    I was experimenting with some basic sample asp code but can't get it to work
    correctly:

    this is bgselector.asp which works OK - you add the name of a basic color
    like blue, green, yellow and call another asp called backcolor.asp where I
    have the problem:

    bgselector.asp
    ---------------------------------
    <html>
    <head>
    <title>Test page</title>
    </head>
    <body>
    form>
    Background Color selector
    <form action ="backcolor.asp" method="post">
    Please type in a valid color e.g blue , green , yellow
    <input type="text" name ="backcolor"><p>
    <input type="submit" value="submit"><p>
    </form>
    </body>
    </html>
    --------------------------------------------

    in backcolor.asp the code that uses the color from bgselector.asp is
    <%
    Dim strBackColor
    strBackColor = Request.Form("backcolor")
    %>

    How do I implement this? Here is what I tried that did not work to change
    the backcolor of backcolor.asp

    <html>
    <head>
    <title>backcolor</title>
    <%
    Dim strBackColor
    strBackColor = Request.Form("backcolor")
    %>
    </head>
    <body bgcolor=<%strBackcolor%>>

    </body>
    </html>

    Any suggestions appreciated.
    Thanks,
    Rich
     
    Rich, Mar 23, 2006
    #1
    1. Advertising

  2. Rich

    Rich Guest

    I figured this out:

    <html>
    <head>
    <title>backcolor</title>
    <%
    Dim strBackColor
    strBackColor = Request.Form("backcolor")
    %>
    </head>
    <body bgcolor=<% response.write strBackColor%>>

    </body>
    </html

    I forgot about <%response.write strBackColor%>


    "Rich" wrote:

    > Hi,
    >
    > I was experimenting with some basic sample asp code but can't get it to work
    > correctly:
    >
    > this is bgselector.asp which works OK - you add the name of a basic color
    > like blue, green, yellow and call another asp called backcolor.asp where I
    > have the problem:
    >
    > bgselector.asp
    > ---------------------------------
    > <html>
    > <head>
    > <title>Test page</title>
    > </head>
    > <body>
    > form>
    > Background Color selector
    > <form action ="backcolor.asp" method="post">
    > Please type in a valid color e.g blue , green , yellow
    > <input type="text" name ="backcolor"><p>
    > <input type="submit" value="submit"><p>
    > </form>
    > </body>
    > </html>
    > --------------------------------------------
    >
    > in backcolor.asp the code that uses the color from bgselector.asp is
    > <%
    > Dim strBackColor
    > strBackColor = Request.Form("backcolor")
    > %>
    >
    > How do I implement this? Here is what I tried that did not work to change
    > the backcolor of backcolor.asp
    >
    > <html>
    > <head>
    > <title>backcolor</title>
    > <%
    > Dim strBackColor
    > strBackColor = Request.Form("backcolor")
    > %>
    > </head>
    > <body bgcolor=<%strBackcolor%>>
    >
    > </body>
    > </html>
    >
    > Any suggestions appreciated.
    > Thanks,
    > Rich
    >
    >
     
    Rich, Mar 23, 2006
    #2
    1. Advertising

  3. Rich

    Evertjan. Guest

    =?Utf-8?B?UmljaA==?= wrote on 23 mrt 2006 in
    microsoft.public.inetserver.asp.general:

    > <%
    > Dim strBackColor
    > strBackColor = Request.Form("backcolor")
    > %>
    > </head>
    > <body bgcolor=<%strBackcolor%>>


    <body bgcolor='<% = strBackcolor %>' >


    >




    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Mar 23, 2006
    #3
  4. Rich

    John Kotuby Guest

    You might also use
    <body bgcolor=<%=strBackcolor%>>

    "Rich" <> wrote in message
    news:...
    >I figured this out:
    >
    > <html>
    > <head>
    > <title>backcolor</title>
    > <%
    > Dim strBackColor
    > strBackColor = Request.Form("backcolor")
    > %>
    > </head>
    > <body bgcolor=<% response.write strBackColor%>>
    >
    > </body>
    > </html
    >
    > I forgot about <%response.write strBackColor%>
    >
    >
    > "Rich" wrote:
    >
    >> Hi,
    >>
    >> I was experimenting with some basic sample asp code but can't get it to
    >> work
    >> correctly:
    >>
    >> this is bgselector.asp which works OK - you add the name of a basic color
    >> like blue, green, yellow and call another asp called backcolor.asp where
    >> I
    >> have the problem:
    >>
    >> bgselector.asp
    >> ---------------------------------
    >> <html>
    >> <head>
    >> <title>Test page</title>
    >> </head>
    >> <body>
    >> form>
    >> Background Color selector
    >> <form action ="backcolor.asp" method="post">
    >> Please type in a valid color e.g blue , green , yellow
    >> <input type="text" name ="backcolor"><p>
    >> <input type="submit" value="submit"><p>
    >> </form>
    >> </body>
    >> </html>
    >> --------------------------------------------
    >>
    >> in backcolor.asp the code that uses the color from bgselector.asp is
    >> <%
    >> Dim strBackColor
    >> strBackColor = Request.Form("backcolor")
    >> %>
    >>
    >> How do I implement this? Here is what I tried that did not work to
    >> change
    >> the backcolor of backcolor.asp
    >>
    >> <html>
    >> <head>
    >> <title>backcolor</title>
    >> <%
    >> Dim strBackColor
    >> strBackColor = Request.Form("backcolor")
    >> %>
    >> </head>
    >> <body bgcolor=<%strBackcolor%>>
    >>
    >> </body>
    >> </html>
    >>
    >> Any suggestions appreciated.
    >> Thanks,
    >> Rich
    >>
    >>
     
    John Kotuby, Mar 23, 2006
    #4
  5. even <body bgcolor=<%=strBackColor%>> works.
     
    ravichoudhari, Mar 24, 2006
    #5
  6. Rich

    Mike Brind Guest

    Or even:

    <html>
    <head>
    <title>backcolor</title>
    </head>
    <body bgcolor=<% =Request.Form("backcolor")%>>

    --
    Mike Brind


    John Kotuby wrote:
    > You might also use
    > <body bgcolor=<%=strBackcolor%>>
    >
    > "Rich" <> wrote in message
    > news:...
    > >I figured this out:
    > >
    > > <html>
    > > <head>
    > > <title>backcolor</title>
    > > <%
    > > Dim strBackColor
    > > strBackColor = Request.Form("backcolor")
    > > %>
    > > </head>
    > > <body bgcolor=<% response.write strBackColor%>>
    > >
    > > </body>
    > > </html
    > >
    > > I forgot about <%response.write strBackColor%>
    > >
    > >
    > > "Rich" wrote:
    > >
    > >> Hi,
    > >>
    > >> I was experimenting with some basic sample asp code but can't get it to
    > >> work
    > >> correctly:
    > >>
    > >> this is bgselector.asp which works OK - you add the name of a basic color
    > >> like blue, green, yellow and call another asp called backcolor.asp where
    > >> I
    > >> have the problem:
    > >>
    > >> bgselector.asp
    > >> ---------------------------------
    > >> <html>
    > >> <head>
    > >> <title>Test page</title>
    > >> </head>
    > >> <body>
    > >> form>
    > >> Background Color selector
    > >> <form action ="backcolor.asp" method="post">
    > >> Please type in a valid color e.g blue , green , yellow
    > >> <input type="text" name ="backcolor"><p>
    > >> <input type="submit" value="submit"><p>
    > >> </form>
    > >> </body>
    > >> </html>
    > >> --------------------------------------------
    > >>
    > >> in backcolor.asp the code that uses the color from bgselector.asp is
    > >> <%
    > >> Dim strBackColor
    > >> strBackColor = Request.Form("backcolor")
    > >> %>
    > >>
    > >> How do I implement this? Here is what I tried that did not work to
    > >> change
    > >> the backcolor of backcolor.asp
    > >>
    > >> <html>
    > >> <head>
    > >> <title>backcolor</title>
    > >> <%
    > >> Dim strBackColor
    > >> strBackColor = Request.Form("backcolor")
    > >> %>
    > >> </head>
    > >> <body bgcolor=<%strBackcolor%>>
    > >>
    > >> </body>
    > >> </html>
    > >>
    > >> Any suggestions appreciated.
    > >> Thanks,
    > >> Rich
    > >>
    > >>
     
    Mike Brind, Mar 24, 2006
    #6
  7. Rich

    Evertjan. Guest

    ravichoudhari wrote on 24 mrt 2006 in
    microsoft.public.inetserver.asp.general:

    > even <body bgcolor=<%=strBackColor%>> works.
    >


    Certainly, but to keep you straight for other insertions, that could have
    spaces in the string, I suggest you always clientside quote the string:

    <body bgcolor='<%=strBackColor%>'>

    =========

    btw, better use css styles:

    <body style='background-color:<%=strBackColor%>;'>

    or even more versatile:

    <style>
    body {background-color:<% = request.form("BackColor") %>;
    color:<% = request.form("TextColor") %>;font-weight:600;}
    </style>
    </head>
    <body>

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Mar 24, 2006
    #7
  8. Rich

    Slim Guest

    "John Kotuby" <> wrote in message
    news:%...
    > You might also use
    > <body bgcolor=<%=strBackcolor%>>


    quite right,

    but you should alos enclose it quotes incase the vaiable is "two words"

    <body bgcolor="<%=strBackcolor%>" >


    >
    > "Rich" <> wrote in message
    > news:...
    >>I figured this out:
    >>
    >> <html>
    >> <head>
    >> <title>backcolor</title>
    >> <%
    >> Dim strBackColor
    >> strBackColor = Request.Form("backcolor")
    >> %>
    >> </head>
    >> <body bgcolor=<% response.write strBackColor%>>
    >>
    >> </body>
    >> </html
    >>
    >> I forgot about <%response.write strBackColor%>
    >>
    >>
    >> "Rich" wrote:
    >>
    >>> Hi,
    >>>
    >>> I was experimenting with some basic sample asp code but can't get it to
    >>> work
    >>> correctly:
    >>>
    >>> this is bgselector.asp which works OK - you add the name of a basic
    >>> color
    >>> like blue, green, yellow and call another asp called backcolor.asp where
    >>> I
    >>> have the problem:
    >>>
    >>> bgselector.asp
    >>> ---------------------------------
    >>> <html>
    >>> <head>
    >>> <title>Test page</title>
    >>> </head>
    >>> <body>
    >>> form>
    >>> Background Color selector
    >>> <form action ="backcolor.asp" method="post">
    >>> Please type in a valid color e.g blue , green , yellow
    >>> <input type="text" name ="backcolor"><p>
    >>> <input type="submit" value="submit"><p>
    >>> </form>
    >>> </body>
    >>> </html>
    >>> --------------------------------------------
    >>>
    >>> in backcolor.asp the code that uses the color from bgselector.asp is
    >>> <%
    >>> Dim strBackColor
    >>> strBackColor = Request.Form("backcolor")
    >>> %>
    >>>
    >>> How do I implement this? Here is what I tried that did not work to
    >>> change
    >>> the backcolor of backcolor.asp
    >>>
    >>> <html>
    >>> <head>
    >>> <title>backcolor</title>
    >>> <%
    >>> Dim strBackColor
    >>> strBackColor = Request.Form("backcolor")
    >>> %>
    >>> </head>
    >>> <body bgcolor=<%strBackcolor%>>
    >>>
    >>> </body>
    >>> </html>
    >>>
    >>> Any suggestions appreciated.
    >>> Thanks,
    >>> Rich
    >>>
    >>>

    >
    >
     
    Slim, Mar 24, 2006
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Abe Simpson
    Replies:
    1
    Views:
    2,485
    Joerg Jooss
    Dec 15, 2005
  2. bart plessers

    dbase: how to get fieldNAME ofa table

    bart plessers, Oct 2, 2003, in forum: ASP General
    Replies:
    4
    Views:
    165
    Bob Barrows
    Oct 2, 2003
  3. geradeaus

    dynamic formname/fieldname

    geradeaus, Apr 21, 2004, in forum: Javascript
    Replies:
    5
    Views:
    114
    Grunken
    Apr 21, 2004
  4. ZZT

    $array.fieldname question

    ZZT, Jun 11, 2004, in forum: Perl Misc
    Replies:
    3
    Views:
    102
    J├╝rgen Exner
    Jun 11, 2004
  5. rajendra

    getting fieldname of excel sheet

    rajendra, Feb 6, 2008, in forum: Perl Misc
    Replies:
    0
    Views:
    92
    rajendra
    Feb 6, 2008
Loading...

Share This Page