Solved

ASP Javascript propogation (calling function from Javascript)

Posted on 2011-03-25
3
371 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 7

Assisted Solution

by:Alpha Au
Alpha Au 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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 demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

623 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