Fill a form field using ASP ??

M

MROPARTNER

I have a field in a form called "Date" I am looking to fill this text
field with the current date. Is there a way to do this with ASP or an
easier way?

Thanks
Bill
 
K

Kevin Spencer

ASP:

<input type="text" name="myText" size="20" value="<%=Now%>">

or client-side JavaScript:

<script type="text/javascript"><!--
document.forms[0].myText.Value = new Date();
// --></script>
<input type="text" name="myText" size="20">

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
M

MROPARTNER

Either one would be fine. I used the example above and it worked as
far as filling the field on my form with the date, but when the submit
button is hit the page just reloads. The form is not sent. The form
was made using Frontpage 2000. Any ideas?

My form can be found at:

http://mropartner.com/WorkOrders_Test.asp

Thanks
 
K

Kevin Spencer

You may want to bone up on how ASP works. My web site
(http://www.takempis.com) has a number of beginner articles and tutorials
that can be helpful to you.

The form is indeed sent. The "Action" attribute of a form indicates the
resource that should handle the form post. In your case, you specified that
the form handler was the same page. Here's the HTML from your form tag:

<FORM METHOD="POST" action="WorkOrders_Test.asp"
webbot-action="--WEBBOT-SELF--">

Note that the handler is the same as the form page itself. The page posts
back to itself.

It looks like you originally created a FrontPage form that is handled by
FrontPage server extensions, and then renamed the form with a .asp
extension. Once you do that, you cannot use FrontPage form handlers for the
form. It has to be handled by an ASP page. In other words, you have to write
your own custom ASP form handler. Again, see my web site to learn the ropes
of ASP.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
G

Guest

Hello Bill,
On my submission_form.asp I also have a date field and I wanted it to
automatically fill in the date.
Double-click on the Text Box to get to the properties.
In the Initial Value field type: <%=Date%>

Now when the users submit the form and it feeds back into my database the
date come through just fine. But, just a word of caution. I might have had
to edit my database field properties to make sure it had date format. I
don't remember. I did a lot of going back and forth to get the date and time
fields to do what I wanted them to do.
Hope it helps
 

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

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top