> -----Original Message-----
> From: [EMAIL PROTECTED] On Behalf Of Jack Killpatrick
> Sent: Friday, November 06, 1998 5:13 PM

> Is there a way to do something like this:
> 
>       var variable_name = 2;
>       form.thing_[variable_name]_deluxe.value;
> 
> for efficiency's sake?

Do you mean other than

        form["thing_"+variable_name+"_deluxe"].value  ?

Of course, you can access the third element in the
form array by

        form[variable_name].value  or  form[2].value

but those are not necessarily the same one as that accessed
by the previous construct.  Positional access should be used
only when you're iterating through the whole array, viz;

        for (var i=0; i<form.length; i++) form[i].value='';

The reason not to use positional access for other things
is that the index value is dependent on the position of the
element in the form.  If you use a numeric constant and 
later someone re-arranges the form, your code breaks.

Btw, considerations of efficiency in an interpreter aren't
always "common sense."  Positional access may be faster than
associative, but not necessarily.

> I think you're saying you have a page setup where the user types (or
> pastes?) a bunch of text into an <input=text> or <textarea> and it is
> rendered elsewhere on the page where the DIV .innerHTML is, right?

Actually that's what my original "cute trick" example does. I
was describing a more elaborate use in which the function that
handles the ONKEYUP event gets values from a bunch of form entries
(first name, last name, e-mail, years at SofTech, etc.) including
a "notes" TEXTAREA in which the user is invited to use HTML tags.
The function manipulates the values from the form and adds HTML tags
of its own to construct the web page, then uses this trick to show
it to the user.  When the user hits SUBMIT, the CGI routine does
almost the same processing to construct the real web page and writes
it to a file on the server.


> you wouldn't believe the grief Allaire got when people found out they
> decided in favor of an MS component for their Homesite 4 product!

Basically the critics wanted them to bypass the best engineering
solution because they (the critics) had a grudge against MS.  Likewise
we're all struggling to support both the MS and NS browsers despite the
significant inferiority of NS, at a cost of much more work, pages that
aren't as good as they could be, and larger downloads.  We're risking
the possibility that the public will lose patience and interest in
the Web.

If NS 4.5 or NS 5 are in compliance with the W3C specs, the risks 
will have been worth it.  However, I have little faith that an
open software product will manage to comply with a standard.

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