wrote:
> Hello,
> for compatibility reasons I have a variable in javascript with periods
> in its name, it is based on a hostname and I need to tie that
> information to the function.
> the variable is function_www.hostname.com
> The problem is when I try to run a simple javascipt program on it, the
> script fails, probably because of the way javascript uses periods, but
> if I remove the periods the script works.
> is there anyway to inclose full hostnames within variable names?
>
> here is a sample of the code:
> function_www.hostname.com =
You can't use dots in an identifier (ECMAScript Spec, section 7.6). It
is entirely unnecessary in a local variable anyway, you could use x or z
or whatever is meaningful to you.
> document.userchange.function_www.hostname.com.chec ked;
Guessing that userchange is the name of a form:
document.userchange.elements['function_www.hostname.com'].checked;
<URL:
http://www.jibbering.com/faq/#FAQ4_25 >
> if (! function_www.hostname.com) {
> if (confirm("Do you want this?")) {
> document.userchange.function_www.hostname.com.chec ked = true;
> }
> }
You might consider something like:
var el = document.userchange.elements['function_www.hostname.com'];
if (!el.checked) {
if (confirm("Do you want this?")) {
el.checked = true;
}
}
--
Rob
"We shall not cease from exploration, and the end of all our
exploring will be to arrive where we started and know the
place for the first time." -- T. S. Eliot