Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling VBScript Function within JavaScript Function

Status
Not open for further replies.

NWChowd

Programmer
May 26, 2002
84
0
0
US
I have a situation in which I need to do something when a user clicks off a page (via the back button, via another link within the website, closes the browser, etc.) Specifically, if the events mentioned above occur, I need to change a database table field value back to its original value. I am able to recognize the events mentioned above via JavaScript, but... I need to call a VBScript function within the JavaScript function. The VBScript function runs a stored procedure which will revert the database table value back to its original value.

I tried inserting some VBScript into the JavaScript function, and, what happens is, the VBScript is interpreted upon loading the page, rather than just sitting idle, and only firing when the JavaScript Function is itself fired.

here is the JavaScript function, if it helps. Also, note the ASP delimiters nested within the JS Function.

function updateStatus()
{
if (window.document.generate.ctr.value == '')
alert ("test");
//need to set status back to previous state
<%
'IMObject_changeStatus Request.QueryString(&quot;inqid&quot;),Request.QueryString(&quot;stat&quot;)
%>
}


Any help or direction is immensely appreciated!!

Regards,

dmill

======================================
&quot;I wish that I may never think the smiles of the great and powerful a sufficient inducement to turn aside from the straight path of honesty and the convictions of my own mind.&quot;
-David Ricardo, classical economist
======================================
 
ASP runs server-side. This means that before the page even gets to the client that the ASP code has already executed and gone away. In order to execute ASP code after a client side event you will need to submit to a new page that contains the script you wish to run. Server-side and client-side code cannot execute simultaneously for the same page. It is like a river where the water only runs one way. There are ways of faking it by embedding inner frames in the page and then using javascript to change the src of the inner frame to the address of your asp script, but besides making the page complicated, it is not cross browser compliant.
-Tarwn The three most dangerous things in the world are a programmer with a soldering iron, a hardware type with a program patch, and a user with an idea
-computer saying (Wiz Biz - Rick Cook)
 
&quot;I need to change a database table field value back to its original value.&quot;

This too is confusing me. Show us the flow of your pages. Which page has the ASP that updates the database? Which page has the Javascript that responds to those events?
 
hi..i m encountering the same problem as u had...may i pls know how u did it..tnx :D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top