PDA

View Full Version : Dashes in INPUT NAME


Bonnie Smyre
08-30-2002, 02:52 PM
Are input names allowed to include dashes? I have a
webpage that has some inputs like this:

<input type="text" name="RC-ENR-LIMIT" value="0001">

That works fine until I try to refer to the textbox with
JavaScript like this:

<a onClick="document.frm.RC-ENR-LIMIT.focus();
document.frm.RC-ENR-LIMIT.select();">ERROR</a>

The JavaScript doesn't do anything. If I change the dashes
to underscores, it works.

Please let me know if you have any
ideas.
Thanks!
Bonnie

pkchukiss
08-30-2002, 02:55 PM
I think you need to put a backslash "/" in front of every instance of "-" in your javascript call.

jkd
08-30-2002, 03:54 PM
Use:

document.frm.elements['RC-ENR-LIMIT'].select()

Bonnie Smyre
08-30-2002, 07:00 PM
document.frm.elements['RC-ENR-LIMIT'].select()
works great -- thanks so much for your help!
-- Bonnie