|
-
Jan 17th, 2005, 10:38 AM
#1
Accessing a form element with a space in between [Resolved]
If I have a dropdown box named so:
Code:
<select name="Dev. Domain">
How would I access it using Javascript?
I tried
document.getElementById("Dev. Domain")
but apparently Firefox doesn't seem to like it. And I am not quite sure it can be used in
document.formname.Dev. Domain (?)...
Any tips?
Last edited by mendhak; Jan 18th, 2005 at 03:59 AM.
-
Jan 17th, 2005, 12:47 PM
#2
Re: Accessing a form element with a space in between
You will need to give it an id if you use the getElementById method.
If you want to access it via the form you would use the form name: document.formname.elementname which will provide you with an array of option elements.
-
Jan 18th, 2005, 01:44 AM
#3
Re: Accessing a form element with a space in between
 Originally Posted by visualAd
You will need to give it an id if you use the getElementById method.
If you want to access it via the form you would use the form name: document.formname.elementname which will provide you with an array of option elements.
And what if it's called "element name"?
document.formname.element name
does not look right.
-
Jan 18th, 2005, 03:08 AM
#4
Re: Accessing a form element with a space in between
- Why does it have a space?
You could try:
document.formname["element name"]
-
Jan 18th, 2005, 03:59 AM
#5
Re: Accessing a form element with a space in between
I can't do anything about the space. Working with an existing form here. 
Thanks for the reply. You're useful for something.
-
Jan 18th, 2005, 08:50 AM
#6
Re: Accessing a form element with a space in between
 Originally Posted by mendhak
I can't do anything about the space. Working with an existing form here.
Thanks for the reply. You're useful for something. 
But was I. I would be interested to know if my suggestion worked, because I cannot be bothered to find out myself.
-
Jan 20th, 2005, 06:25 AM
#7
Re: Accessing a form element with a space in between [Resolved]
I went with the getElementById(" ") thing. I had forgotten to put an id attribute in there, as you pointed out.
I don't have the page with me right now. Wanted to get rid of it as soon as possible.
-
Jan 21st, 2005, 05:26 PM
#8
Re: Accessing a form element with a space in between [Resolved]
A space is not valid in either the id or name attribute. Browsers will accept it, of course (I think they're far too forgiving), but it's not valid according to the HTML specs and can therefore cause all kinds of problems.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 21st, 2005, 10:36 PM
#9
Re: Accessing a form element with a space in between [Resolved]
As it should be. I was working on an existing HTML page that linked to an existing web application that had that parameter. I don't know what was going through their minds at the time, but it's what they put in. I'm glad I get someone to blame in this case
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|