Solved

ASP Javascript propogation (calling function from Javascript)

Posted on 2011-03-25
3
361 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:alphaau
alphaau earned 200 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 300 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 Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now