Unchangeable field in a form??

M

Mike

I have a form that I want the current Date to be one of the fields but I
want that field to be unchangeable. I want the person filling out the form
to see the date but can that field be grayed out or something?

Right now my code is like this:

<%OPTION EXPLICIT%>
<%Dim CurDate%>

<%
CurDate = Date()
%>

I am setting the initial value for the field like this:

<input type="text" name="CurrentDate" size="20" value="<%response.write
CurDate%>"></p>

Thanks,

Mikeal
 
J

Jim Buyens

-----Original Message-----
I have a form that I want the current Date to be one of
the fields but I want that field to be unchangeable. I
want the person filling out the form to see the date but
can that field be grayed out or something?
Right now my code is like this:

<%OPTION EXPLICIT%>
<%Dim CurDate%>

<%
CurDate = Date()
%>

I am setting the initial value for the field like this:

<input type="text" name="CurrentDate" size="20" value="<%response.write
CurDate%>"></p>

The usual approach is to display the data as ordinary
text, and then either:

o Incorporate the date a second time, as a hidden form
field, or
o Have the ASP page that updates the database get the
currentl date directly, instead of from the form.

The code for the first case would look like this:

<%=CurDate%><input type="hidden" name="CurrentDate"
value="<%=CurDate%>">

The code for the second case would vary depending on how
you performed the database update.

Jim Buyens
Microsoft FrontPage MVP
(e-mail address removed)
http://www.interlacken.com
Author of:
*------------------------------------------------------*
|\----------------------------------------------------/|
|| Microsoft Office FrontPage 2003 Inside Out ||
|| Microsoft FrontPage Version 2002 Inside Out ||
|| Web Database Development Step by Step .NET Edition ||
|| Troubleshooting Microsoft FrontPage 2002 ||
|| Faster Smarter Beginning Programming ||
|| (All from Microsoft Press) ||
|/----------------------------------------------------\|
*------------------------------------------------------*
 
P

Peter Taurins

If you client should NEVER change the field, then don't put into a field.

<%response.write CurDate%>

Use this instead of the field formatting and the date will be shown but
obviously not editable.

If you need to pass the value of this field along to other programs, but
only want the client to VIEW and not CHANGE it, use the above method AND add
a hidden field to contain the same value.

<input type="hidden" name="CurrentDate" size="20" value="<%response.write
CurDate%>">

HTH.
PWT.
 
T

Thomas A. Rowe

Use:

<input type="text" name="CurrentDate" size="20" value="<%=CurDate%>"
readonly>

--

==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, Forums, WebCircle,
MS KB Quick Links, etc.
==============================================
 

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

Top