Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ASP Javascript propogation (calling function from Javascript)

Posted on 2011-03-25
3
Medium Priority
?
377 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 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

719 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