473,396 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

<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
6 1337
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jochen Daum | last post by:
Hi ! If I have an input field <form ... method="post"> <input type="text" name="abc def"> </form>
4
by: Dan Jacobson | last post by:
Using <A name="x_y-z"></A>, I even get nervous about the _ and -. w3-recs/RECS/html4/struct/links.html seems to say all of ascii is cool and beyond. Anyway, just what is the safe range for...
6
by: Java script Dude | last post by:
We just discovered another IE bug. When an html form contains an element with a name of `name` IE's internal index screws up the .name property of the containing form to point to the bad element...
3
by: Pavils Jurjans | last post by:
Hello, I have bumped upon this problem: I do some client-side form processing with JavaScript, and for this I loop over all the forms in the document. In order to identify them, I read their...
6
by: Just Me | last post by:
My Task List contains the following: At least one reference is missing the 'Name' attribute. Any suggestion on how toe find which project is missing it? Solution contains 25 projects. ...
4
by: ajschuster | last post by:
I cannot get my Javascript to work in Firefox. I am just trying to access the .name property of a DIV tag but it keeps coming back as "undefined". The same code works in IE and it works in...
5
by: Alex Maghen | last post by:
The editor says that when using <a name="xyz" />, the "name" element is "obsolete" but it doesn't suggest a replacement. What's wrong with <a name="xyz" /> to set a page anchor?
6
by: Dick Watson | last post by:
I had a page that works when setup like this: === <form name="frmCalc" action=""> <script type="text/javascript"> function btnCalc_onclick(abc) { return "got here with " + abc; }
3
by: idorjee | last post by:
Hi, Can anyone please tell me if there is a way to hyperlink to a web page which doesn't have the anchor "name" attribute (e.g., <a name="thename">), but has tags such as, <strong>. So, my question...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.