INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Checking input date agains a file of holidays

Checking input date agains a file of holidays

(OP)
Hi All

What I am trying to do is output a message "Holiday" immediately after entering a date using the following JavaScript.

CODE

<script type="text/javascript">
    var noHols = "<%=iNoHols%>"
    function datePickerClosed(dateField) {
        var HolArray = new Array();
        document.getElementById("DateMess").value = noHols;
    }
</script> 

It last line will eventually be replaced with

CODE

document.getElementById("DateMess").value = "Holiday; 

There will obviously also be some code to check the date, but first I need to get some variables from ASP. I have set these up using the following

CODE

dim dStartHols(100), dEndHols(100)
holsSql = "SELECT Start_Date, End_Date from lawn_holidays " &_
            "Where UserID='" & Request.Cookies("userid") & "' " &_
            "AND Van=" & iVan
            
response.write holsSql & "<BR>"
set holsRS=DBconn.execute(holsSql)

iNoHols=-1 'because arrays start from zero
if holsRS.BOF and holsRS.EOF then
    response.write "empty" & "<br>"
else
    response.write "Full" & "<br>"
	do until holsRS.eof
        iNoHols = iNoHols + 1
		dStartHols(iNoHols) = holsRS("Start_Date")
		dEndHols(iNoHols) = holsRS("End_Date")
		holsRS.movenext
	loop
    'because arrays start from zero, if 1 holiday, then will have value 0
end if 
My problem is reading iNoHols, dStartHols and dEndHols in the JavaScript. You can see I have tried to get iNoHols in the code above and display it in the last line. I have googled this for days and var noHols = "<%=iNoHols%>" seems to be the way to go, but no joy. Can you see what I am doing wrong?

Thanks

RE: Checking input date agains a file of holidays

Quote:

Can you see what I am doing wrong?

Trying to make javascript 'talk' ASP vBscript. Never ever going to happen. ASP code is done and finished with before the javascript even gets to the browser never mind starts to run.

You either do everything server side with round trips using form data, or use AJAX to 'talk' to the server side system.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: Checking input date agains a file of holidays

Yes Chris absolutely right...
you can stick somewhere in javascript array of holidays and check against that array or use ajax call from javascript to server with selected value and get from another asp page on server result

RE: Checking input date agains a file of holidays

Hi

Not totally sure I understand, but from the point of view of javascript being able to see the asp - order is everything.

CODE --> asp

<%
dim dStartHols(100), dEndHols(100)
holsSql = "SELECT Start_Date, End_Date from lawn_holidays " &_
            "Where UserID='" & Request.Cookies("userid") & "' " &_
            "AND Van=" & iVan
            
response.write holsSql & "<BR>"
set holsRS=DBconn.execute(holsSql)

iNoHols=-1 'because arrays start from zero
if holsRS.BOF and holsRS.EOF then
    response.write "empty" & "<br>"
else
    response.write "Full" & "<br>"
	do until holsRS.eof
        iNoHols = iNoHols + 1
		dStartHols(iNoHols) = holsRS("Start_Date")
		dEndHols(iNoHols) = holsRS("End_Date")
		holsRS.movenext
	loop
    'because arrays start from zero, if 1 holiday, then will have value 0
end if 
%> 

CODE --> javascript

<script type="text/javascript">
    var noHols = "<%=iNoHols%>";
    function datePickerClosed(dateField) {
        var HolArray = new Array();
        document.getElementById("DateMess").value = noHols;
    }
</script> 

As long as iNoHols is set in the first ASP bit, it will be usable in the javascript.

}...the bane of my life!
http://www.gamified.uk
http://www.fuzzyd.co.uk

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close