Go4Expert

Go4Expert (http://www.go4expert.com/)
-   ASP (http://www.go4expert.com/forums/asp/)
-   -   ASP javascript (http://www.go4expert.com/forums/asp-javascript-t698/)

ammo 9Apr2006 01:00

ASP javascript
 
please read this code
Code: ASP

<%@ 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:

aspguy 9Apr2006 08:15

Re: ASP javascript
 
The default scripting language on your server is Jscript. Try putting

<%@ Language=VBScript %>

pradeep 10Apr2006 10:39

Re: ASP javascript
 
There is no such keyword as Set in JavaScript, its used in VBScript.

Code: ASP

/* 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.


All times are GMT +5.5. The time now is 14:20.