Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 11th, 2005, 01:39 AM
okl okl is offline
Registered User
 
Join Date: Mar 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default passing js var to asp sql

 hi, i trying to call savetime() on window onUnload.
But the sql give me an error.
Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error in UPDATE statement.

I debug the sql output it gave me blank, nothing shown.

Thanks for the help!
Code:
<html>
<head>
<title>Question 1</title>

<SCRIPT>
var interval = "";
var hr  = <%=objRst("hrs")%>;
var min = <%=objRst("mins")%>;
var sec = <%=objRst("secs")%>;

function startInterval()
{
    interval = window.setInterval("tTimer()",1000);
}

function stopInterval()
{
    window.clearInterval (interval);
    interval="";
}

function savetime()
{
<%
hrLeft = Request.form("Hr")
MinLeft = Request.form("Min")
SecLeft = request.form("Sec")

strSQL = "UPDATE Attempts SET Hrs=" & HrLeft & ",Mins=" & MinLeft & ",Secs=" & SecLeft & " WHERE studentID ='" & Session("StudID") & "' AND Paper = '" & Session("Paper") & "'"
'response.write strsql
'response.end
objConn.Execute (strSQL)
%>
}

function tTimer()
{
    document.timerform.display.value = hr+':'+zeroPad(min)+':'+ zeroPad(sec--);

    if (sec == -1)
    {
        if (min!="00")
        {
          min = min-1;
          sec = 59;
        }
        if (hr!=0)
        {
          hr = hr-1;
          min = 59;
          sec = 59;
        }
        if (hr==0 && min=="00")
        {
           stopInterval();
           alert ("TIME'S UP");
        }
   }
}
function zeroPad(digit)
{
    if (digit>9) {
      return digit;
    }
    return "0" + digit;
}
</SCRIPT>
</head>


<body bgcolor="#CCFFFF" onUnload="saveTime()">
<script>
startInterval();
</script>

  <form name="timerform" method="POST" action="Q1_Calc.asp" onsubmit="return validate()">

<input type="text" name="display" value="" size="10" readonly>

 
Old March 11th, 2005, 05:01 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi okl,

You are probably not seeing your
Code:
response.write strsql
output in the browser because it is being written into a script block. If you view the source of the page, you should see what you are after.

BTW, your asp code is serverside & gets executed before the page is sent to the client machine. Therefore you db will get updated when the page builds, not when saveTime() gets called.

HTH,

Chris






Similar Threads
Thread Thread Starter Forum Replies Last Post
passing empty parameters to a js function crmpicco Javascript How-To 0 September 20th, 2005 10:16 AM
passing js var to asp sql okl Javascript 1 March 11th, 2005 05:40 AM
passing parameter from js to another jsp page. Regornil JSP Basics 1 August 31st, 2004 08:23 AM
passing var from parent to child darkhalf Javascript 6 April 13th, 2004 09:27 PM
Asp Results in var prgaspar Classic ASP Basics 4 August 19th, 2003 07:24 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.