Solved

ASP Javascript propogation (calling function from Javascript)

Posted on 2011-03-25
3
367 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Update field in order 21 141
Need help to rewrite script 3 79
Issues with Insert statement 12 26
Hide cell in a table 2 12
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
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 demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

772 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