[thelist] JS embroidery

Rory.Plaire at wahchang.com Rory.Plaire at wahchang.com
Fri Sep 21 14:37:50 CDT 2001

OK, folks,

Here is my cloud of anxiety on an otherwise bright horizon:

I have an HTML select. I have set the onFocus event handler to initialize a
global variable, iLastIndex, when the select gets the focus, which happens,
of course, when it is clicked. This is used to do some calculations later on
how far the selection has traveled in the list by hooking the onChange
handler with a function which takes the control and determines its
selectedIndex property and adds or subtracts the iLastIndex value. The
difference is then used to modify a value in a textbox. This works great
when the user interacts with it.

Now, I have a "master" select on the form which determines which point in
the list all of the selects on the page are at -- i.e. it modifies the
selectedIndex of all the other select widgets on the page. Since the value
of that textbox is intimately dependent on the item in the select widget,
this needs to change, too. So, I call focus() on the select widget to invoke
the custom onFocus event handler and set that global value. Then I
programmatically change the selectedIndex property of the select, and call
the function which changes the textbox value to suit the new list position
according to how far it traveled.

It don't work.

The values in the textbox don't change.

*EXCEPT* if I add an alert() after each call to focus().

I think there are some complex thread issues here. The only thing I don't
think is that I have the capacity currently to comprehend what to do.

What I want to do is synchronize the thread dispatching the call to focus()
and the one which calls the successive property change and function to
change the textbox value. The question is "How?"

Can someone help me crawl out of this box?

<tip type="SQL Server">
When building a database, try to craft the tables, views, stored procedures,
etc from hand. TSQL, the custom flavor of ANSI SQL-92 which MS builds into
SQL Server, can easily do this and more in creating your database. You can
even tune, manage and report on it.

But, to the point. If you take the time to hand script all your database
objects, not only do you learn intimately the basic and most fundamental way
to work with SQL Server and thus lunge ahead in the effort to get that MCDBA
cert, should be of them that drink this kool-aid, you can also make
modifications to the scripts and drop and recreate those objects in a flash,
while you are prototyping the solution for your client.

I like to use Query Analyzer to create them. It color codes all the TSQL
statements and reserved words, and can check your code without executing it.
It also has a host of nifty tools which can help you analyze your query by
reporting the query plan and the execution time, etc. Finally, a well-named
tool from MS! (Think: do you commonly write only one word with Word?)


<tip type="SQL Server">
Using Query Analyzer?

Here's one that changed my life:
If you select only a portion of the SQL you are crafting with the cursor,
and press F5 or similarly execute it, only that portion is executed!

Now I pour all my test coding scraps into one window and select only the one
I need!

Remember to select the text before the execute, especially if you have
DELETE or <gulp!> DROP statements! I generally comment these out (double
hyphen [--] before the line, or /*comment*/) just in case... then I can
still select the text without the comment delimiters and execute!

<rory disposition="Ahhh... the bittersweetness of Friday!" alt="8}"/>

More information about the thelist mailing list