Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old June 6th, 2003, 06:04 AM
Registered User
 
Join Date: Jun 2003
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Auto update of text box/label

Dear Sir/Madam,

I have an ongoing issue with my ASP application. I am developing a Intranet site to enable employees to enter their holiday dates. When they enter the holiday dates I want to have a label or text box which updates with the number of days holiday they are requiring to book. Is this possible to do? Could you point me in the right direction. I am new to ASP and don't really know where to start.

Thanks in advance.


Regards,

Simon Dilley.
  #2 (permalink)  
Old June 6th, 2003, 07:00 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

If you want to do it entirely in ASP, you'll need to post the dates to the server then calculate the number of days and re-display the page including the calculated value and the original inputs.

Alternatively you could use a bit of javascript (or maybe even vbscript if your in an IE only intranet scenario) on the client-side which reads the input values, calculates the days and displays the result on the page without having to go to the server and back. Here's a quick 'n' dirty example which shows how to get values from input boxes and write to the page in client-side vbs.

<html>
<head>
<script language="VBScript">
Sub CalcDays()
    Dim dtStart, dtEnd, nDiff, sMsg

    dtStart = document.frmDate.txtStart.value
    dtEnd = document.frmDate.txtEnd.value

    If IsDate(dtStart) and IsDate(dtEnd) Then
        nDiff = 1 + DateDiff("d", dtStart, dtEnd)
        sMsg = nDiff & " days"
    Else
        sMsg = "valid dates only"
    End If

    document.getElementById("dvMsg").innerHTML = sMsg
End Sub
</script>
</head>
<body>
<form name="frmDate" id="frmDate">
Start Date : <input type="text" name="txtStart" id="txtStart"><br>
End Date : <input type="text" name="txtEnd" id="txtEnd"><br>
<div id="dvMsg"> </div><br>
<input type="button" value="Get Days" onclick="CalcDays">
</form>
</body>
</html>

hth
Phil


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Text in Label funnylearning .NET Framework 2.0 2 September 18th, 2006 12:59 PM
Auto-Filling a Text box based on Multiple Boxes zuldan23 Access VBA 1 May 5th, 2006 10:17 AM
Unattach Label from Text Box sweet4511 Access VBA 4 July 20th, 2005 11:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.