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')
}
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 ?
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
Powered by phpBB © phpBB Group.