By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,398 Members | 1,351 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,398 IT Pros & Developers. It's quick & easy.

Problem with Javascript with TDC control

P: n/a
I have inherited code with a TDC control. In this file, there are two
javascripts of interest. One of these is a function, filter(), which is
inside
<script language=javascript></script>.

The other is code inside
<script language=javascript FOR=inquiry
event=ondatasetcomplete()></script>
where inquiry is the TDC.

The table displays correctly. The problem is in getting the total after
doing a display and then refreshing the TDC (which invokes the script
filter() ). That calculation is done in the second script. What
happens in there is:
var rs = inquiry.recordset;
extcosttot = 0;
num = rs.Fields.Count;
while(rs.EOF != true)
{
extcosttot += parseFloat(rs(9).value);
rs.moveNext;
}

When I alert inside the while loop, the very first record from before
the sorting -- even though the table display properly with the new one.

I tried to put similar looping code at the end of filter() to examine
what I get from the TDC refresh, but I got a messages of "Operation is
not allowed when the object is closed". When I added an open() for I
got "The connection cannot be used to perform this operation. It is
either closed or invalid in this context".

I am at a bit of a loss. I have no idea what happens between the end of
filter() and the inline script and I have no idea on how to
successfully put in code to see what is at the end of filter().

Since there is no code in the generator file for how the sorting is
taking place, the problem must be after retrieving the recordset,
observing somehow that it was left at a certain column being sorted, and
then sorting it accordingly.
Sep 1 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
sheldonlg wrote:
I have inherited code with a TDC control. In this file, there are two
javascripts of interest. One of these is a function, filter(), which is
inside
<script language=javascript></script>.

The other is code inside
<script language=javascript FOR=inquiry
event=ondatasetcomplete()></script>
where inquiry is the TDC.

The table displays correctly. The problem is in getting the total after
doing a display and then refreshing the TDC (which invokes the script
filter() ). That calculation is done in the second script. What
happens in there is:
var rs = inquiry.recordset;
extcosttot = 0;
num = rs.Fields.Count;
while(rs.EOF != true)
{
extcosttot += parseFloat(rs(9).value);
rs.moveNext;
}

When I alert inside the while loop, the very first record from before
the sorting -- even though the table display properly with the new one.

I tried to put similar looping code at the end of filter() to examine
what I get from the TDC refresh, but I got a messages of "Operation is
not allowed when the object is closed". When I added an open() for I
got "The connection cannot be used to perform this operation. It is
either closed or invalid in this context".

I am at a bit of a loss. I have no idea what happens between the end of
filter() and the inline script and I have no idea on how to
successfully put in code to see what is at the end of filter().

Since there is no code in the generator file for how the sorting is
taking place, the problem must be after retrieving the recordset,
observing somehow that it was left at a certain column being sorted, and
then sorting it accordingly.
I worked my way around to avoid the problem (not by fixing it), but I
would still like to know what caused this problem in the first place.

The call of a filter is done in a javascript routine with setting the
DataURL and doing inquiry.Reset() where inquiry is the name of the
dataset object. When it is complete, it calls another javascript (via
using ondatasetcomplete). The getting of this refreshed dataset has no
knowledge of any sorting that may have taken place on the columns prior
to doing the refresh, and the ondatasetcomplete is done automatically
upon getting the refreshed data.

What I would like to know is this:
*************
Why does the looping through the dataset give all the proper records
(sorted) except for the first record which is from the unsorted set?
*************

For anyone who may be interested, the way I avoided the problem was to
add an extra field to the dataset. In the display page, I set the style
of that column to "display:none". In that field, I place the cumulative
total for all the records, and all records hold the same total. In the
DataURL, I delayed writing of the records by putting them into an array,
and at the end of the fetching, modifying all the lines in the array by
setting the same cumulative total into that last field. Then I print out
the entire array in the appropriate format.
Sep 2 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.