Preserved Topic: form element has a hyphen... oh dear... (Page 1 of 1) |
|
---|---|
Bipolar (III) Inmate From: Scotland |
posted 11-10-2001 19:38
I have a page that when you click on tickboxes, it updates a textarea. I'm working with someone elses CGI and cannot change form or element "names". As you'll see, I have 'document.messaging.X-E3-Recipients.value' and JS falls over because of the hyphens (it must thing I mean "minus"). (messaging is the form name, X-E3-Recipients is the textarea name.) |
Bipolar (III) Inmate From: Scotland |
posted 11-10-2001 20:13 |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 11-10-2001 20:36
Yeah, you could probably also have used document.messaging["X-E3-Recipients"].value too. But whoever created a form with hyphens in the name was an idiot. |
Bipolar (III) Inmate From: Scotland |
posted 11-10-2001 23:40 |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 11-11-2001 00:15
I think you want to set it to a *string* - "0123456789". It's a litle complicated how strings and numbers work in javascript. |
Bipolar (III) Inmate From: USA! USA! USA! |
posted 11-13-2001 17:06
I couldn't disagree more about the use of hyphens in HTML. Since the standard clearly supports them, one would be ignorant to discount their use at all times. |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 11-13-2001 18:28
Sure, hyphens are allowed in HTML. They're not allowed in JavaScript variable names, however, and when you're setting the name of a form element, you're setting it's JavaScript variable name. That, I think, is the only place that hyphens aren't allowed in HTML - since it's not *really* HTML inside the name="jsvarname" quotes. No more than init() is HTML within onload="init()". |
Bipolar (III) Inmate From: USA! USA! USA! |
posted 11-26-2001 22:33
code: <form name="my-form">
|