In addition to Bustarooms answer you can also specify the RmOneEnd field Readonly to avoid misuse of users editing the field.
This can be done by,
<input type="text" name="RmOneEnd" ReadOnly>
Main Topics
Browse All TopicsHi
First of all apologies for asking a question that has been asked before but despite trying I do not seem to be able to access the full answers so need to re-submit it as a new request
I have a Form in MS FrontPage that records information from prospective customers to a small Bed & Breakfast hotel. I would like to simplyfy the users input to prevent miscalculation of their booking dates. To this end on my Form I have three fields
RmOneStart
NightsStop
RmOneEnd
I would like to be able to have the RoomOneEnd field updated automaticaly on exiting the NighstStop field. I think in Access code it would be
DateAdd('Days!, NightsStop, RmOneStart)
or something similar but how to do it in Java or Jscript I don't know.
The RoomOne End Should show the Date on the morning of leaving for example
If I booked a room Starting on the 1st of the month and wanted to stay for 7 Nights the leaving day would be the 8th of the month. I hope this makes sense
Mike
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi,
the following (tested in IE6, NN6.1, NN4.7) is based on Bustaroom's, but I changed the nightstops to a selection list and provided a default value for the RmOneStart value
the ReadOnly attribute is not crossBrowser -- onfocus='this.blur()' is
<html>
<head>
<script language="javascript">
function updateEnd(formObj)
{
var selObj = formObj.days;
var start = formObj.RmOneStart.value
var stay = selObj.options[selObj.sele
if(start != '' && stay != '')
{
var tempLeave = new Date(start);
tempLeaveMilli = Date.parse(tempLeave)
if(isNaN(tempLeaveMilli)){
alert('Enter a valid date');
formObj.RmOneStart.select(
formObj.RmOneStart.focus()
return false;
}
if(isNaN(stay)){
alert('Enter a valid stay');
formObj.NightsStop.value='
formObj.NightsStop.focus()
return false;
}
tempLeaveMilli = tempLeave.valueOf() + stay*100000000;
var leave = new Date(tempLeaveMilli);
formObj.RmOneEnd.value= (leave.getMonth()+1) + '/' + leave.getDate() + '/' + leave.getFullYear();
}
}
function init()
{
today = new Date();
month = today.getMonth();
date = today.getDate();
year = today.getFullYear();
defaultDate = month + "/" + date + "/" + year
document.checkout.RmOneSta
}
</script>
</head>
<body onload='init()'>
<form name="checkout">
Check in:<input type="text" name="RmOneStart" onblur="updateEnd(this.for
<select name="days" onchange="updateEnd(this.f
<option selected>Number of Days</option>
<option value="1" >1</option>
<option value="2" >2</option>
<option value="3" >3</option>
<option value="4" >4</option>
<option value="5" >5</option>
<option value="6" >6</option>
<option value="7" >7</option>
</select>
<br>
Check out:<input type="text" name="RmOneEnd" onfocus='this.blur()'>
</form>
</body>
</html>
Vinny
Thanks guys the program works fine however, I have a problem with date formats, us english guys write the date the proper way :-) dd/mm/yyyy but with your script(s) the screens keep reverting to the US format mm/dd/yyyy. Unfortunately this will confuse us older Brits who have trouble adapting to new fangled ways. I have had a look at the scripts to see if I could modify them myself and despite switching around the functions I found that had Month; Date; year as the order which threw up some bizarre results, I found nothing that would convert the date format.
Any suggestions?
Mike
Hi Mike,
here you go
<html>
<head>
<script language="javascript">
function updateEnd(formObj)
{
var selObj = formObj.days;
var start = formObj.RmOneStart.value
tmp = start.split("/")
start = tmp[1] + '/' + tmp[0] + '/' + tmp[2]
var stay = selObj.options[selObj.sele
if(start != '' && stay != '')
{
var tempLeave = new Date(start);
tempLeaveMilli = Date.parse(tempLeave)
if(isNaN(tempLeaveMilli)){
alert('Enter a valid date');
formObj.RmOneStart.select(
formObj.RmOneStart.focus()
return false;
}
if(isNaN(stay)){
alert('Enter a valid stay');
formObj.NightsStop.value='
formObj.NightsStop.focus()
return false;
}
tempLeaveMilli = tempLeave.valueOf() + stay*100000000;
var leave = new Date(tempLeaveMilli);
formObj.RmOneEnd.value= leave.getDate() + '/' + (leave.getMonth()+1) + '/' + leave.getFullYear();
}
}
function init()
{
today = new Date();
month = today.getMonth();
date = today.getDate();
year = today.getFullYear();
defaultDate = date + "/" + month + "/" + year
document.checkout.RmOneSta
}
</script>
</head>
<body onload='init()'>
<form name="checkout">
Check in:<input type="text" name="RmOneStart" onblur="updateEnd(this.for
<select name="days" onchange="updateEnd(this.f
<option selected>Number of Days</option>
<option value="1" >1</option>
<option value="2" >2</option>
<option value="3" >3</option>
<option value="4" >4</option>
<option value="5" >5</option>
<option value="6" >6</option>
<option value="7" >7</option>
</select>
<br>
Check out:<input type="text" name="RmOneEnd" onfocus='this.blur()'>
</form>
</body>
</html>
Vinny
First of all apologies to my contributers, I have not tried to do you out of your points it's just there has been some confision over my accounts which I am trying to get sorted. Once that is done I plan to increase the points to 500 and split between Vincent and Bustaroom as Busta's was the basis of Vinny's scripts but Vinny has done some additional work on it for me. Will that be acceptable to you both?
Mike
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:
Split: Bustarooms {http:#9513627} & VincentPuglia {http:#9527413}
Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
jAy
EE Cleanup Volunteer
I have increased this to 500 points. Apologies to Bustarooms and Vincent for my tardiness but other matters overtook and I was somewhat distracted by a bout of ill health. I will post 300 points to bustarooms as the instigator of the fix and 200 to Vincent for his modifications of the original. I hope this is acceptable
Business Accounts
Answer for Membership
by: BustaroomsPosted on 2003-10-08 at 07:42:19ID: 9513627
below is an example of what you might be looking for .com/cal_e xample.htm l
_________ ); ; '; ; m)"><br> m)"><br> _________
you might want to also consider using a date-picker to perform the process of selecting the date. this will help to reduce errors
Here is jaysolomon's example that i like to pimp out http://jaysolomon.fateback
__________________ EXAMPLE __________________________
<html>
<head>
<script language="javascript">
function updateEnd(theForm){
var start = theForm.RmOneStart.value
var stay = theForm.NightsStop.value
if(start != '' && stay != ''){
var tempLeave = new Date(start);
tempLeaveMilli = Date.parse(tempLeave)
if(isNaN(tempLeaveMilli)){
alert('Enter a valid date');
theForm.RmOneStart.select(
theForm.RmOneStart.focus()
return false;
}
if(isNaN(stay)){
alert('Enter a valid stay');
theForm.NightsStop.value='
theForm.NightsStop.focus()
return false;
}
tempLeaveMilli = tempLeave.valueOf() + stay*100000000;
var leave = new Date(tempLeaveMilli);
theForm.RmOneEnd.value= (leave.getMonth()+1) + '/' + leave.getDate() + '/' + leave.getFullYear();
}
}
</script>
</head>
<body>
<form>
Check in:<br><input type="text" name="RmOneStart" onblur="updateEnd(this.for
Stay:<br><input type="text" name="NightsStop" onblur="updateEnd(this.for
Check out:<br><input type="text" name="RmOneEnd">
</body>
</html>
_________________ EXAMPLE __________________________