Re: validate a form and choosing a link
- From: Richard Cornford <Richard@xxxxxxxxxxxxxxxxxxx>
- Date: Tue, 4 Aug 2009 03:28:08 -0700 (PDT)
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.
.
- References:
- validate a form and choosing a link
- From: Pascal
- Re: validate a form and choosing a link
- From: Jonathan Fine
- validate a form and choosing a link
- Prev by Date: Re: FAQ suggestion: Does JavaScript have classes and instances?
- Next by Date: Re: Not being rude, not complaining of rudeness
- Previous by thread: Re: validate a form and choosing a link
- Next by thread: Re: validate a form and choosing a link
- Index(es):
Relevant Pages
|