Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically populating a form field 1

Status
Not open for further replies.

mellenburg11

Programmer
Aug 30, 2004
9
US
I was on an ASP page that asked for my name. I typed my name into the form and when I left the field, either through tabbing or clicking on the next field, it automatically converted what I typed to uppercase. I wanted to see the source code for this page but it would not let me.

I need to do a similar function where a user would enter a date and I would like that date to automatically populate another date field on the same form. The user would then be able to change the second date if necessary or do nothing if that date is correct.

How to you make a page pass information without using a submit button? Can ASP do this or is this a javascript or some other code running on the ASP page?
 
This would be javascript. It's quite simple though. For the first date input tag use something like:
onchange="document.form1.date2.value=document.form1.date1.value;"

The syntax might be slightly off, but that's the basic concept. You might also want to call a javascript function instead.
 
Thank you Jeremy, that did the trick. I also have a javascript calendar that fills the first date field by clicking on the date. When I use the calendar rather than entering the date by hand, it does not automatically populate the second date field. Is there something about that javascript that makes the page ignore the 'onchange' command? If so, are there other HTML commands instead of 'onchange' that would work for both types of entry?
 
I'm not sure how your calender script works. I assume its basically using a similar javascript command. Take a look at the code and see if you can find where it actually fills in the field. Then add that onchange code there as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top