By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,626 Members | 1,929 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,626 IT Pros & Developers. It's quick & easy.

"name" attribute.......more than one use?

P: n/a
<a href="#" name="sample">link 1</a>
<a href="#" name="sample">link 2</a>

Would this be invalid use of the name?
If I wanted to have a function that would be acted upon by detection of the
"name", would this happen if all "name"s in a group were the same?
I know ID can only be used once per document, what about "name"?

If this is invalid, then if I went by a unique ID, such as sample1, sample2,
sampl3, is there a way to eliminate the number on the end to check if the
strings match what I'm looking for?

For those of you familiar with ancient BASIC, we could easily do this by
saying something like A$=left$(b$,6).
Where A$ would return the first 6 characters of b$.
So does JS have an equivelant?
Jul 23 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Lee
Richard said:

<a href="#" name="sample">link 1</a>
<a href="#" name="sample">link 2</a>

Would this be invalid use of the name?
If I wanted to have a function that would be acted upon by detection of the
"name", would this happen if all "name"s in a group were the same?
I know ID can only be used once per document, what about "name"?
The name attribute does not have to be unique.
Your use is valid.

If this is invalid, then if I went by a unique ID, such as sample1, sample2,
sampl3, is there a way to eliminate the number on the end to check if the
strings match what I'm looking for?

For those of you familiar with ancient BASIC, we could easily do this by
saying something like A$=left$(b$,6).
Where A$ would return the first 6 characters of b$.
So does JS have an equivelant?


A=b.substr(0,6)

Jul 23 '05 #2

P: n/a
On 15 Jan 2005 19:43:42 -0800 Lee wrote:
Richard said:
<a href="#" name="sample">link 1</a>
<a href="#" name="sample">link 2</a> Would this be invalid use of the name?
If I wanted to have a function that would be acted upon by detection of
the
"name", would this happen if all "name"s in a group were the same?
I know ID can only be used once per document, what about "name"? The name attribute does not have to be unique.
Your use is valid.
If this is invalid, then if I went by a unique ID, such as sample1,
sample2,
sampl3, is there a way to eliminate the number on the end to check if
the
strings match what I'm looking for? For those of you familiar with ancient BASIC, we could easily do this
by
saying something like A$=left$(b$,6).
Where A$ would return the first 6 characters of b$.
So does JS have an equivelant?

A=b.substr(0,6)

Thank you. I thought it must have.
Jul 23 '05 #3

P: n/a
Richard wrote:
<a href="#" name="sample">link 1</a>
<a href="#" name="sample">link 2</a>

Would this be invalid use of the name?
Yes - read the spec. In regard to <a> tags:

"This attribute names the current anchor so that it may be the
destination of another link. The value of this attribute must be a
unique anchor name. The scope of this name is the current document.
Note that this attribute shares the same name space as the id
attribute."

<URL:http://www.w3.org/TR/html4/struct/links.html#adef-name-A>

All tag attributes and the tags that they apply to, along with links
to explainations of each are here:

<URL:http://www.w3.org/TR/html4/index/attributes.html>

Whenever you are tempted to ask a question such as that above, read the
spec first.

If I wanted to have a function that would be acted upon by detection of the
"name", would this happen if all "name"s in a group were the same?
I know ID can only be used once per document, what about "name"?


Sometimes name must be unique, sometimes is should not be used and
sometimes it is mandatory. Check the specification each time you want
to use it.

--
Rob
Jul 23 '05 #4

P: n/a
Lee wrote:
Richard said:
<a href="#" name="sample">link 1</a>
<a href="#" name="sample">link 2</a>
[...]
The name attribute does not have to be unique.
Your use is valid.


Wrong. In regard to named links, the name attribute *must* be unique
and it shares the same namespace as ID, so it must not match an ID
either.

--
Fred
Jul 23 '05 #5

P: n/a
On Sun, 16 Jan 2005 14:48:37 +1000 RobG wrote:
Richard wrote:
<a href="#" name="sample">link 1</a>
<a href="#" name="sample">link 2</a> Would this be invalid use of the name?
Yes - read the spec. In regard to <a> tags: "This attribute names the current anchor so that it may be the
destination of another link. The value of this attribute must be a
unique anchor name. The scope of this name is the current
document.
Note that this attribute shares the same name space as the id
attribute." <URL:http://www.w3.org/TR/html4/struct/links.html#adef-name-A> All tag attributes and the tags that they apply to, along with links
to explainations of each are here: <URL:http://www.w3.org/TR/html4/index/attributes.html> Whenever you are tempted to ask a question such as that above, read
the
spec first.

I would if I knew how w3 was structured to find these things out.
Like they make it so easy.
I thought it had to be unique but I wasn't sure if that was correct or not.
Jul 23 '05 #6

P: n/a
Richard wrote:
[...]
Whenever you are tempted to ask a question such as that above, read
the
spec first.


I would if I knew how w3 was structured to find these things out.
Like they make it so easy.
I thought it had to be unique but I wasn't sure if that was correct or not.


Here is the start of the W3C HTML 4.01 spec. It is the table of
contents and has links to everything to do with HTML.

<URL:http://www.w3.org/TR/html4/>

At the bottom are links to references, notably a list of all the
elements and all the attributes.

The only way to get to know it is to start using it - think of an
element, say <p> and look it up, it's in chapter 9, titled:

"Text - Paragraphs, Lines, and Phrases"

Click the link, it takes you here:

<URL:http://www.w3.org/TR/html4/struct/text.html>

Or, to go via the Index of elements, go to the bottom of the table of
contents (where references are normally listed), and click on the link
to here:

<URL:http://www.w3.org/TR/html4/index/elements.html>

scroll down to "P", click on it and you go here:

<URL:http://www.w3.org/TR/html4/struct/text.html#edef-P>

Now you know how I use it, try it.
--
Rob.
Jul 23 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.