1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

ASP javascript

Discussion in 'ASP' started by ammo, Apr 8, 2006.

  1. ammo

    ammo New Member

    Joined:
    Apr 5, 2006
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    please read this code
    Code:
    <%@ language="javascript"%>
    <html>
    	<head>
    		<script language="javascript">
    		<!--
    			function validate(noofticks,avail)
    			{
    				alert("Inside validate");
    			}
    		-->
    		</script>
    	</head>
    	<body>
    		<%
    			Set MyConn = Server.CreateObject("ADODB.Connection")
    			MyConn.Open <<hidden for security>>
    			var rc,dt,mt,avail
    			rc=Request.Form("rcode")
    			dt=Request.Form("da")
    			mt=Request.Form("mo")
    			SQL_query="select * from route_booking_details"
    			Set RS=MyConn.Execute(SQL_query)
    			while(RS.EOF != 0)
    			{
    				if(rc == RS("Rcode") && dt == RS("Date") && mt == RS("Month"))
    				{
    					if(RS("Count") < 40)
    					{
    						Response.write("No. of tickets available = " & (40-RS("Count")))
    						avail = 40 - RS("Count")
    						Response.write("<form name='noofticks' onSubmit='return validate(this,avail)' 
    
    action='http://localhost/Project/confirm.asp' method='post'>")
    						Response.write("Enter no. of tickets to book : ")
    						Response.write("<input type='text' name='num'>")
    						Response.write("<br>")
    						Response.write("<input type='submit' value='Book Tickets'>")
    					}
    					else
    					{
    						Response.write("Sorry...the bus is full. No tickets available")
    					}
    					RS.Close
    					MyConn.Close
    					Response.End
    				}
    				RS.MoveNext
    			}
    			Response.write("No. of tickets available = 40")
    			RS.Close
    			MyConn.Close
    			
    		%>
    	</body>
    </html>
    this is the code.
    this is a .asp file in an iis server.
    now i am getting the following error in the browser....

    Error Type:
    Microsoft JScript compilation (0x800A03EC)
    Expected ';'
    /Project/ch_avail.asp, line 15, column 4
    Set MyConn = Server.CreateObject("ADODB.Connection")
    ---^

    what is the error !!! i put the semi colon at the end of the stmt just to check...still the same error. plz debug for me. :confused:
     
    Last edited by a moderator: Apr 9, 2006
  2. aspguy

    aspguy New Member

    Joined:
    May 2, 2005
    Messages:
    59
    Likes Received:
    1
    Trophy Points:
    0
    The default scripting language on your server is Jscript. Try putting

    <%@ Language=VBScript %>
     
  3. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,646
    Likes Received:
    86
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    There is no such keyword as Set in JavaScript, its used in VBScript.

    Code:
    /* not like this */
     Set MyConn = Server.CreateObject("ADODB.Connection")
     /* like this */
     var myConn;
     MyConn = Server.CreateObject("ADODB.Connection");
    Moreover, you did not use the line delimiter.
     

Share This Page