Re: validate a form and choosing a link



On Aug 4, 10:36 am, Jonathan Fine wrote:
Pascal wrote:
hello i am new to javascript and I am trying to send the visitor
of my page to another depending what he feeds in the form but
there is an error i can't figure ! Can you help me to find it
please?

the error says line 27 carac 3 voc is undefined and if I put 0
instead of voc, it works ! Why ? The value of this radio button
is voc ! not 0

In
object[aaa] = bbb
the key is aaa and the value is bbb.

In a bracket notation property accessor the name of the property is
determined by evaluating the expression within the square brackets and
then type-converting the result into a string to give the property
name (the thing you are unhelpfully referring to as "the key"). In
both the original code and your example the expression in the brackets
is an Identifier, which means a scope chain lookup of the Identifier
to retrieve its value. In the event of the Identifier having never
been declared as a variable, function's formal parameter or function
name an error will result from the attempt to retrieve its value.

What you (and the OP) want inside the square brackets is an expression
that will evaluate to a value that either is a string in which the
character sequence corresponds with the desired property name (your
"the key"), or will type-convert into that string. The simplest such
expression is a string literal; - object["aaa"] - in your case and -
document.formulaire.matiere["voc"] - in the OP's.

I suggest that the key is indead 0.
<snip>

Yes, <INPUT type="radio"> sets are not indexable by their VALUE
attributes, only by integer index, which is why - 0 - (the index of
the first radio button in the set) works and, even without the use of
the undeclared Identifier - voc -, the named property access would
not.

Richard.
.



Relevant Pages

  • Double Linked List Help
    ... 256 characters long identified in the input file F. Each identifier ... identifier, length is an integer representing the length of the ... string is a string of characters representing the identifier itself. ...
    (comp.lang.c.moderated)
  • Re: kde4 and opengl
    ... server glx vendor string: NVIDIA Corporation ... Identifier "Simple Layout" ...
    (comp.windows.x.kde)
  • RE: regular expressions. Order matters?
    ... order does matter in a Regex. ... That way, if it can enclose the word in square brackets, it will. ... > I am trying to create a regular expression that will let me know if a string ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: puzzling results from dlookup
    ... Since the field name begins with a number, use square brackets around the ... Year is a VBA function, and it will confuse Access if you use it as a ... thinks is a missing operator. ... Criteria string is correctly formed. ...
    (microsoft.public.access.formscoding)
  • Re: Countif in VB Script
    ... identifies/keeps track of its patients. ... However, they use a wrist band identifier, which is usually not subject ... The collection keeps track what it has stored by using a unique string ... colvalues.add vbNullString, CStr.value) ...
    (microsoft.public.excel.programming)