How to set default value in request.form?

Discussion in 'ASP General' started by Ragnar Heil, Aug 22, 2004.

  1. Ragnar Heil

    Ragnar Heil Guest

    I have got a form where I offer a default date (01.01.2004) and visitors
    can change it and make queries in the database.
    After changing this, the customized date should be displayed in the form
    instead of the default one.

    If Request.Form("BeginDate") <> "" then
    iBeginDate = "01.01.2001"
    end if
    ....

    <input name="BeginDate" type="text" class="form" value="<%=Request.Form
    ("BeginDate")%>

    Now the entered date keeps, that's fine, but when at the first visit
    there is no default date



    best regards
    R.
    Ragnar Heil, Aug 22, 2004
    #1
    1. Advertising

  2. Ragnar Heil

    Evertjan. Guest

    Ragnar Heil wrote on 22 aug 2004 in
    microsoft.public.inetserver.asp.general:
    > If Request.Form("BeginDate") <> "" then
    > iBeginDate = "01.01.2001"
    > end if
    > ...
    >
    > <input name="BeginDate" type="text" class="form"
    > value="<%=Request.Form ("BeginDate")%>
    >
    > Now the entered date keeps, that's fine, but when at the first visit
    > there is no default date


    Try in your thinking to keep serverside and clientside apart.
    The server will render a html code ready for the client [=browser].

    <%
    BeginDate = trim(Request.Form("BeginDate"))
    If BeginDate = "" then
    BeginDate = "01.01.2001"
    end if
    %>

    <input
    name="BeginDate"
    type="text"
    class="textInput"
    value="<%= BeginDate %>"
    >


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Aug 22, 2004
    #2
    1. Advertising

  3. You're looking for something along the lines of

    value =
    <% if request("beginDate") = "" the response.write "01.01.2004"
    else
    response.write request("beginDate")
    end if%>

    Be careful though when using dates since there's such a plethora of
    issues with having your visitors enter the dates manually as in ...

    What if they enter 01/01/2004?
    or January 1, 2004?
    or 1 Jan 2004?
    What if they enter 4/3/2004 do they mean April 3, 2004 or March 4, 2004?

    David H


    Ragnar Heil wrote:

    > I have got a form where I offer a default date (01.01.2004) and visitors
    > can change it and make queries in the database.
    > After changing this, the customized date should be displayed in the form
    > instead of the default one.
    >
    > If Request.Form("BeginDate") <> "" then
    > iBeginDate = "01.01.2001"
    > end if
    > ...
    >
    > <input name="BeginDate" type="text" class="form" value="<%=Request.Form
    > ("BeginDate")%>
    >
    > Now the entered date keeps, that's fine, but when at the first visit
    > there is no default date
    >
    >
    >
    > best regards
    > R.
    David C. Holley, Aug 22, 2004
    #3
  4. Ragnar Heil

    Ragnar Heil Guest

    "David C. Holley" <> wrote in
    news::

    > Be careful though when using dates since there's such a plethora of
    > issues with having your visitors enter the dates manually as in ...
    >
    > What if they enter 01/01/2004?
    > or January 1, 2004?
    > or 1 Jan 2004?
    > What if they enter 4/3/2004 do they mean April 3, 2004 or March 4,
    > 2004?


    I don't see a way that all kind of date-styles can be entered.
    So I offer them a default date (01.12.2004) which they can modify. It is
    a German website,so they won't enter the date this way: 12.01.2004

    After entering values in the form the visitors gets search-results back.
    The customized values remain for a little while when I go from Page 1 to
    Page 2 and so on. But if I jump a bit, the values are lost. Now I am
    using a default date to prevent an error message. Is the only way to
    solve this to use session variables?


    regards. Ragnar
    Ragnar Heil, Aug 31, 2004
    #4
  5. Ragnar Heil

    David Holley Guest

    1) Although you may be building a 'German' site, you can't control who's
    going to us or their nationality - even if its for an INTRAnet.
    Accepting this and controlling the date format will actualy make for a
    stronger, better design.

    2) What do you mean by 'if a jump around a bit'? What specific steps
    result in the default value being lost?

    As a side note, its not neccessary to session variables. Setting a
    cookie with the default value should suffice.

    David H

    www.gatewayorlando.com

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    David Holley, Aug 31, 2004
    #5
    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. Christian H
    Replies:
    1
    Views:
    856
    Natty Gur
    Jul 29, 2003
  2. Brian Birtle
    Replies:
    2
    Views:
    1,998
    John Saunders
    Oct 16, 2003
  3. C Gillespie
    Replies:
    3
    Views:
    396
    Peter Hansen
    Mar 22, 2005
  4. SibAndela
    Replies:
    1
    Views:
    179
    Jeff Cochran
    Sep 26, 2004
  5. Guest
    Replies:
    2
    Views:
    131
    Bob Barrows [MVP]
    Feb 20, 2006
Loading...

Share This Page