Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ASP Javascript propogation (calling function from Javascript)

Posted on 2011-03-25
3
Medium Priority
?
379 Views
Last Modified: 2012-05-11
Hi all

I have the code below..

I need to check the value of currentDate in the database
and raise alert if the current date submitted is available
before calling the test.asp!
How can I modify the code below to achive this

Thanks in advance..
<%


	function checkDate()
		varDate = Request.Form("currentDate")
		cmd.ActiveConnection = conn
		cmd.CommandText = "checkDate"
		cmd.CommandType = adCmdStoredProc
		cmd.Parameters.Append cmd.CreateParameter ("@myDate",adVarChar,adParamInput ,10,varDate)
		cmd.Parameters.Append cmd.CreateParameter ("@Count_Dates",adInteger,adParamOutput)
		cmd.Execute 
		intNumber = cmd.Parameters ("@Count_Dates")
	Set cmd = nothing
	Response.Write (intNumber)
	end function

%>
 
<html>
 <head>
   <script language="javascript">
     function test(intNumber)
     {
       if (intNumber != 0)
       {
         
 
        alert("This date exist in the system");
       }     
     }
   </script>
 </head>

 <body>
   

   <form name="form1" method="post" action="test.asp">
     <input type="hidden" name="testid">
     <input type="hidden" name="callfunction" value="yes">	
	 <input name="currentDate" type="text" value="" size="10" maxlength="10"/> 
	<input type="submit" value="Submit" />
   </form>
 </body>
</html>

Open in new window

0
Comment
Question by:ZURINET
3 Comments
 
LVL 7

Assisted Solution

by:Alpha Au
Alpha Au earned 800 total points
ID: 35213787
in order to connect to db, you must use server side code,

if you need to do it in the javascript part,

you'll need to use the ActiveXObject("MSXML2.XMLHTTP")

you may have a look on this
http://www.jibbering.com/2002/4/httprequest.html
0
 

Author Comment

by:ZURINET
ID: 35213834
Hi Alphauu

The isse with connect db is no problem..

My problem is I need to compare user input varaible with the value in DB and return an alert to the user if
a certain condition is not met..

can I solve this with asp script and javascript alone?
0
 
LVL 22

Accepted Solution

by:
Om Prakash earned 1200 total points
ID: 35214881
You can use AJAX for this. Once user clicks on the button, call the server side page and check the existance of date.

Please check the following example:
http://www.w3schools.com/Ajax/ajax_database.asp
0

Featured Post

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.

Question has a verified solution.

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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

876 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