Total members 11793 |It is currently Fri Aug 23, 2019 12:12 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





I have a javascript function (getStatus) that will call a second function (GetTableRowCount) 11 times to retrieve the row counts of 11 different tables.

I created a simplified version of my javascript that will only call getTableRowCount once for the first table. I cannot figure out how to return the rowcount from getTableRowCount to GetStatus. I added a bunch of alert messages and it appears that I do not understand the sequence in which things are executed. Based on the simplified script below, I get the alert messages in the following order:

1) alert('Bottom of getTableRowCount')
2) alert('In getStatus');
3) alert('Return ' + row['rCount']);

I would have expected it to be
1) alert('Return ' + row['rCount']);
2) alert('Bottom of getTableRowCount')
3) alert('In getStatus');


What am I missing? I have tried to move the return statement to different sections of the function but that doesn't seem to fix my issue. Any help would be appreciated. Please excuse the formatting as I can't get it to work just right for this posting.

FIRST FUNCTION

function getStatus(){
var retVal = getTableRowCount('master_area');
alert('In getStatus');
}

SECOND FUNCTION

function getTableRowCount(tableName){
var query = 'SELECT count(*) AS rCount from ' + tableName;

db.transaction(function(transaction){
transaction.executeSql(query, [], function(transaction, results){

var row = results.rows.item(0);
alert('Return ' + row['rCount']);
return(row['rCount']')
}, function(transaction, error){
updateStatus("Error: " + error.code + "Message: " + error.message);
});
});

alert('Bottom of getTableRowCount')
}




Author:
Newbie
User avatar Posts: 1
Have thanks: 0 time

What i remember that if you want to run Javascript at server you may use runat="server" attribute like this :
Code:

<SCRIPT LANGUAGE="JavaScript" src="readDb.asp" runat="server"></SCRIPT>


also where is the place to open connection to database just like adding username password and such thinks ?


Author:
Mastermind
User avatar Posts: 2707
Have thanks: 74 time
Post new topic Reply to topic  [ 2 posts ] 

  Related Posts  to : Need help getting rowcount from local table using javascript
 use local user dll from website - usar dll local del usuario     -  
 Local Web designers     -  
 VB/Oracle Developer-Must be local to Minnesota     -  
 Calling a local variable from a static function     -  
 Display Visitor's Local Time (IPv6 supported)     -  
 different between Local variable and Global variable     -  
 Local variables vs Instance variables     -  
 table creation     -  
 table row hover     -  
 Creating table using div tag     -  









Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com