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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

javascript function call from asp-code

Status
Not open for further replies.

JohnBeton

Programmer
Feb 9, 2004
21
BE
Hi everyone,

I have a stupid problem, but i can't get it to work:

i have this function to format a date:

<script type="text/javascript" language="JavaScript">
<!--
function convertDate(DT){
parts = DT.split('-');
if (parts[0] < 13){
datum = parts[1] + "/" + parts[0] + "/" + parts[2];
}else{
datum = parts[0] + "/" + parts[1] + "/" + parts[2];
}
return datum;
}
//-->

then i want to use this function to build an sql-query:

datum = request.form("txtDatum")
strSql = "select * from BW_Web where datum=#" & convertDate(datum) & "# order by DUBN asc;"

but this won't work...
Maybe someone has a solution for this ?
thanks already

Wim
 
This is a common thread here: you can't call client-side scripting on the server side. Javascript is client-side, ASP is server-side. The Javascript doesn't exist until it gets to the client, and the ASP scripting doesn't exist after it's sent to the client. Rewrite the function in VBScript and put the function inside your ASP tags, not <script> tags, and it'll do what you need.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top