Re: Problem with Javascript with TDC control



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.
.



Relevant Pages

  • Re: Curious IE 6 SP2 error.
    ... I shan't post any of the script as I don't think it would do anything ... similar "Permission Denied" error on a page where the Javascript isn't ... Looking at the page received in the refresh it is identical to the ... short page telling the browser client to refresh the page straight away ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • image cache causes trouble, setInterval and innerHTML fail, together, to get me a new image
    ... It automatically uploads the image to my server. ... I thought it would be fun to have a Javascript function that actually ... this following function does not refresh ... But the script doesn't go back to the server's harddrive ...
    (comp.lang.javascript)
  • Page refresh throws JavaScript error
    ... If JavaScript is not present, or CSS 2 isn't supported, the page just shows a complete list of dated entries. ... If JavaScript is present and CSS 2 is supported, a subset of the list is shown and a button appears in the upper right, which the user can press to see the complete list. ... Inline script thread ... It seems to me that either there's a browser bug here or there is something I don't know about how JavaScript is processed on a page refresh from a remote server. ...
    (comp.lang.javascript)
  • Re: simple script that allows random images to appear
    ... The built-in ASP ... >> appear upon page refresh is not cooperating at all. ... >> me in the direction of a script that will accomplish this? ... > c) JavaScript may be disabled. ...
    (comp.lang.javascript)
  • Re: Move computers account to another OU from a txt list
    ... I need a script, that list from OU or txt file, that contains machine ... user objects by changing the ADO filter in the loop. ... ' Change the base of the query to a specific OU. ... ' Filter on all user objects. ...
    (microsoft.public.windows.server.scripting)