How to set default value in request.form?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ragnar Heil

    How to set default value in request.form?

    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("B eginDate") <> "" then
    iBeginDate = "01.01.2001 "
    end if
    ....

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

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



    best regards
    R.
  • Evertjan.

    #2
    Re: How to set default value in request.form?

    Ragnar Heil wrote on 22 aug 2004 in
    microsoft.publi c.inetserver.as p.general:[color=blue]
    > If Request.Form("B eginDate") <> "" then
    > iBeginDate = "01.01.2001 "
    > end if
    > ...
    >
    > <input name="BeginDate " type="text" class="form"
    > value="<%=Reque st.Form ("BeginDate" )%>
    >
    > Now the entered date keeps, that's fine, but when at the first visit
    > there is no default date[/color]

    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.Fo rm("BeginDate") )
    If BeginDate = "" then
    BeginDate = "01.01.2001 "
    end if
    %>

    <input
    name="BeginDate "
    type="text"
    class="textInpu t"
    value="<%= BeginDate %>"[color=blue]
    >[/color]

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    • David C. Holley

      #3
      Re: How to set default value in request.form?

      You're looking for something along the lines of

      value =
      <% if request("beginD ate") = "" the response.write "01.01.2004 "
      else
      response.write request("beginD ate")
      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:
      [color=blue]
      > 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("B eginDate") <> "" then
      > iBeginDate = "01.01.2001 "
      > end if
      > ...
      >
      > <input name="BeginDate " type="text" class="form" value="<%=Reque st.Form
      > ("BeginDate" )%>
      >
      > Now the entered date keeps, that's fine, but when at the first visit
      > there is no default date
      >
      >
      >
      > best regards
      > R.[/color]

      Comment

      • Ragnar Heil

        #4
        Re: How to set default value in request.form?

        "David C. Holley" <DavidCHolley@n etscape.net> wrote in
        news:u0tFlwDiEH A.712@TK2MSFTNG P09.phx.gbl:
        [color=blue]
        > 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?[/color]

        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


        Comment

        • David Holley

          #5
          Re: How to set default value in request.form?

          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



          *** Sent via Developersdex http://www.developersdex.com ***
          Don't just participate in USENET...get rewarded for it!

          Comment

          Working...