468,539 Members | 1,769 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,539 developers. It's quick & easy.

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("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.
Jul 19 '05 #1
4 6752
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)
Jul 19 '05 #2
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.


Jul 19 '05 #3
"David C. Holley" <Da**********@netscape.net> wrote in
news:u0*************@TK2MSFTNGP09.phx.gbl:
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
Jul 19 '05 #4
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!
Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by dmiller23462 | last post: by
4 posts views Thread by rn5a | last post: by
10 posts views Thread by Brad Baker | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.