Switch to full style
HTML,DHTML,Javascript,XML,CSS
Post a reply

Need help getting rowcount from local table using javascript

Wed Oct 17, 2012 5:37 pm

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')
}



Re: Need help getting rowcount from local table using javascript

Sun Oct 21, 2012 12:11 pm

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 ?

Post a reply
  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     -