How to set default value in request.form?

R

Ragnar Heil

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.
 
E

Evertjan.

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"
 
D

David C. Holley

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
 
R

Ragnar Heil

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
 
D

David Holley

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top