> -----Original Message-----
> From: [EMAIL PROTECTED] On Behalf Of Jack Killpatrick
> Sent: Friday, November 06, 1998 11:38 AM


> >     form["thing_"+number+"_deluxe"].value = "joey";
> 
> ... I don't quite understand why it works, though. 

It works because "form" is an associative array of the elements
in the form.  The references

        form["thing_"+2+"_deluxe"]
        form.thing_2_deluxe
        form["thing_2_deluxe"]

are equivalent.


> ... I guess javascript replaces the first [ with a dot? 

No, that's not a good way to think about the functioning of
an interpreter or compiler; they don't in any sense modify
the code that they're executing.  JS evaluates the expression
"thing_"+2+"_deluxe", get the value "thing_2_deluxe", and
then uses that to access the array "form"


> An addition to this code, to make it work in stinkin NS4 
>
>       document.form["thing_"+number+"_deluxe"].value = "joey";

Sorry, I normally do it that way, because I think the document
is more readable in general with fully-qualified names, but you
had not so I snipped out the "document."  Note that I don't
really do full qualification, leaving out the "window." up
front; JS is downloaded in full source form, so being too
fanatic about qualification just makes the download larger.


> I tried your "cute trick" ... and isn't that snazzy!

One of my uses of it is a form that is processed by a PERL
CGI program to create a web page.  I can show the user filling
out the form exactly what the web page will look like
dynamically, avoiding the round-trip to the server.  My
JS code gets values from other elements in the form and
applies the method ".replace(/\n\r/g,'<P>')" to the text
(replacing blank lines with <P>) before assigning it to
the DIV .innerHTML.

> would be nice to be able to write text to a particular spot
> on the page, other than into a text box, 

The JS code that lets you put a cursor into arbitrary text
and type in new stuff is pretty simple; my example used the
TEXTAREA input so that the basic function wouldn't be obscured.

> on ALL browsers.

Aye, there's the rub.  As far as I know this is all legal
W3C ECMAScript and DOM, but Microsoft is the only browser
that come even close to supporting the standard.  This is
the reason that I recently expressed my regret at the rabid
anti-Microsoft tone of many of the messages on this list.
Of course, I was immediately blasted for daring to suggest
that the Evil Microsoft could ever do something right.

Bob Munck


____________________________________________________________________
--------------------------------------------------------------------
 Join The Web Consultants Association :  Register on our web site Now
Web Consultants Web Site : http://just4u.com/webconsultants
If you lose the instructions All subscription/unsubscribing can be done
directly from our website for all our lists.
---------------------------------------------------------------------

Reply via email to