[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


web form to populate a date field and automatically populate other date fields with dates.

Posted on 2005-04-25
Medium Priority
Last Modified: 2012-06-21
i am trying to design a web form that allows a user to add a date

so for eg:

the user enters 01/01/2005 in the first box

there are 5 other date fields in the form

each of these is populated with a date based on the value entered in the first box

so the other  date fields will populate with

1st blank date field automatically updated with =  01/01/2005 + 7 days
2nd blank date field automatically updated with = 01/01/2005 + 14 days
3rd blank date field automatically updated with = 01/01/2005 + 46 days

any help or guidance on this would be greatly appreciated. thank you in advance

Question by:westlondonsun
LVL 12

Expert Comment

ID: 13857256
Dim D As Date

D = Text1.Text  'whatever user entered

1stDateField =  DateAdd("d", 7, D)
2ndDateField DateAdd("d", 14, D)
3rdDateField DateAdd("d", 46, D)


Author Comment

ID: 13858151
a little confused.

on the above line :
D = Text1.Text  'whatever user entered

how does the browser know that d = whatever the user entered?

Does the user have to click submit. i dont acctually want the user to press any buttons. i want the user to simply enter the date in dd/mm/yyyy format in the first text field and then the others automatically update??

thanks for ur speedy reply
LVL 12

Expert Comment

ID: 13858491
I have never done web programming but what I can say is that you need some sort of event.  Does the Text field give any client side event.  I think there is OnChange and OnExit.  If your users will be moving focus to another control after entering the date then use OnExit if not you may have to use OnChange (which will happen every keypress I think) then check if the text in the control is a valid date
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

LVL 11

Expert Comment

ID: 13858984
To populate an input box in a HTML page, you need to find the name of the input box from the html. Here is a sample i just plucked from one of my other answers:

Add a webbrowser control (press control+t then select "Microsoft Internet Controls" and add it to your form) and a command button and paste the following. When the page is fully loaded - press the command button:

Private Sub Command1_Click()
 MsgBox WebBrowser1.Document.All("myName").Value
End Sub

Private Sub Form_Load()
 WebBrowser1.Navigate2 "http://www.angelfire.com/electronic2/experts/test.html"
End Sub

If you look at the source for the page, the input box is defined by:

 <input type=text name=myName value="testing.....">

And i used the name property to reference the control and get the value.


And if you want to put text into the textbox, use:

WebBrowser1.Document.All("myName").Value = "myText"
LVL 13

Accepted Solution

rettiseert earned 400 total points
ID: 13859017
Try this (the dates will be updated after the first boxt losft focus):

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

   Function UpdateDates()
            if isdate(form1.originalDate.value) then
            form1.originalDatePlus7.value = dateadd("d", 7, cdate(form1.originalDate.value))
                  form1.originalDatePlus14.value = dateadd("d", 14, cdate(form1.originalDate.value))
                  form1.originalDatePlus46.value = dateadd("d", 46, cdate(form1.originalDate.value))
                  form1.originalDatePlus7.value = "invalid date"
                  form1.originalDatePlus14.value = "invalid date"
                  form1.originalDatePlus46.value = "invalid date"                  
            end if
   End Function

<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="">
 <p>Insert your date:
  <input type="text" name="originalDate" onchange="UpdateDates()">
 <p>Date + 7d
  <input type="text" name="originalDatePlus7">
 <p>Date +14d
  <input type="text" name="originalDatePlus14">
 <p>Date + 46d
  <input type="text" name="originalDatePlus46">

Author Comment

ID: 13859084
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<form name="form1" method="post" action="">
Dim txtcharge As Date
dim txthearing As Date
dim txtplea As Date
dim txtpretrial As Date
dim txttrial As Date
dim txtsentence As Date

txtcharge = Text1.Text  'whatever user entered

txthearing =  DateAdd("d", 7, D)
txtplea DateAdd("d", 7, D)
txtpretrial DateAdd("d", 35, D)
txttrial DateAdd("d", 49, D)
txtsentence DateAdd("d", 63, D)

  <input name="txttrial" type="text" id="txttrial2">
    <input name="txtcharge" type="text" id="txtcharge">
    date of charge</p>
    <input name="txthearing" type="text" id="txthearing">
    date of first hearing</p>
    <input name="txtplea" type="text" id="txtplea">
    date of plea</p>
    <input name="txtpretrial" type="text" id="txtpretrial">
    date of pre trial</p>
  <p> date of trial</p>
    <input name="txtsentence" type="text" id="txtsentence">
    date of sentence</p>
    <input type="submit" name="Submit" value="Submit">

can anyone see from the above code, what i have missed or not put into the code yet


Expert Comment

ID: 13859506
You did put a text box on your frm and called it Text1 didn't you?

Are you developing for Windows or for the web? That looks like a web form with VB added? ASP? ASP.NET?

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month20 days, 2 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question