In article <pxj2c.694705$JQ1.149439@pd7tw1no>,
"Grahammer" <postmaster@127.0.0.1> wrote:
> Sorry for the newbie questions...
>
> Is there a link somewhere that shows what defines a valid form object
> (element) name or ID?
>
While HTML allows more characters in the name, you may run into problems
with certain characters. It depends on how you plan on accessing the
variable in JavaScript.
To put the names directly in JavaScript statements
<input type="hidden" name="required_reg_type_1" value="">
document.forms[0].required_reg_type_1.value
I'd go with this:
Letters and numbers plus underscore.
"First, you cannot use any reserved keywords as a variable name."
"Variable names have a couple of other important restrictions. Avoid
all punctuation symbols except for the underscore character. Also, the
first character of a variable name cannot be a numberal." from
JavaScript Bible 4th edition by Danny Goodman.
Or as pointed out ealier in this thread. You can use the quoted way of
access in html name. This could be the preferred style. I do not know.
I guess to address the interaction between how JavaScript and HTML
define names, you can be assured by using the quoted style or make sure
your names do not conflict with JavaScript. I tend to make all my
variable names contain at least two words, such as requiredRegType1 or
required_reg_type_1.
Robert
|