Refrencing Images

H

HTML-JSClub

Anyone know how to refrence images? like GetElementByID except for
images. I alread tried ...ByID ...ByName ...ByValue GetImageBy[previous
ones].
 
R

Random

<img ... id=foo name=foo />

document.images[0] === document.images[ 'foo' ] ===
document.getElementById( 'foo' );
 
M

Michael Winter

<img ... id=foo name=foo />

document.images[0] === document.images[ 'foo' ]

Assuming 'foo' is the first image in the document, otherwise the index
(0) will be different.
=== document.getElementById( 'foo' );

Even when an id attribute value is present on an image in a HTML
document, it is preferable to use the images collection above. It is
supported on more user agents and is self-documenting.

Mike
 
R

Random

hands[ 1 ].add( new Thumb( { direction: 1 } ) );

or, rather,

hands[ 'right' ].add( new Thumb( { direction: 'up' } ) );
 
H

HTML-JSClub

i'm wondering, can i put in stead of a # in /document.images[0]/, can i
put a variable /document.images[myimg]/?
 
H

HTML-JSClub

never mind that, new problem: why isn't this working?
document.images[imgfile] === document.images[currX] ===
document.getElementById(currX).src="man.jpg";
 
H

HTML-JSClub

LOL, i keep solving my own problems (needed 3 ===) thx for all your
help Micheal , "Random"
 
R

Randy Webb

HTML-JSClub said:
LOL, i keep solving my own problems (needed 3 ===) thx for all your
help Micheal , "Random"

Now all we have to do is manage to teach you how to quote and reply
properly.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
 
H

HTML-JSClub

sry i had asked a question but when i solved it i deleted it off the
thread, i thought i had deleted the one you just quoted too.
the question was " Why isnt this working? document.images[0] ===
document.images[ 'foo' ] ===
document.getElementById( 'foo' ). src = 'image.jpg' "
The answer was that i needed 3 === after .src
sry for the confusion
 
M

Michael Winter

never mind that, new problem: why isn't this working?
document.images[imgfile] === document.images[currX] ===
document.getElementById(currX).src="man.jpg";

All you want is:

document.images[currX].src = 'man.jpg';
<img ... id=foo name=foo />

document.images[0] === document.images[ 'foo' ] ===
document.getElementById( 'foo' );

the point was that you could use

document.images['foo'] or,
document.getElementById('foo')

to refer to it. If that image was the n'th image in the document, you
could also use

document.images[ <n> ]

instead. The intent wasn't for you to use all of them.

Mike
 
R

Randy Webb

HTML-JSClub said:
sry i had asked a question but when i solved it i deleted it off the
thread, i thought i had deleted the one you just quoted too.
the question was " Why isnt this working? document.images[0] ===
document.images[ 'foo' ] ===
document.getElementById( 'foo' ). src = 'image.jpg' "
The answer was that i needed 3 === after .src
sry for the confusion

And you still missed the most important part of what I posted.

<quote>

Now all we have to do is manage to teach you how to quote and reply
properly.

</quote>

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
 
H

HTML-JSClub

OK I'M SORRY!!!! and I finally get it thanks to Micheal and if i'm
still missing the point than i have NOOOOOO idea what you're talking
about.
 
H

HTML-JSClub

o....k..... i dont remember quoting anything. And now I have a
question: in switch statements can i have it like:
case str1:
or does it have to be a string or number?
 
H

HTML-JSClub

ooooooooooohh!!! OK i get it now. When quoting someone i add <quote>
and </quote> around it. right?
 
L

Lasse Reichstein Nielsen

HTML-JSClub said:
ooooooooooohh!!! OK i get it now. When quoting someone i add <quote>
and </quote> around it. right?

No. Look what most other people do in this group:

You should quote(!) enough of the post you are responding to, for
giving an understandable context for your answer. How much is enough
is debatable, but everything is often too much (except, as here, where
the message wasn't very large) and nothing is always too little. You
have consistently quoted nothing.

You should put your reply below the quote that it refers to. If you
reply to several points of a message, quote and answer each in this
way.

Quotes must be attributed. While there are raging debates about how
much an attribution needs, it should be sufficient for the reader
to recognize the poster being quoted, if the reader is familiar
with that poster already. My newsreader software uses a very short
version, which I find adequate (although a date would probably be
good).

Quotes should be marked by having their lines prefixed with "> ".
When quoting quotes, the space is not necessary, so a quoted quote
could be prefixed by ">> ". Together with the attribution, the
"quoting level" makes it possible to see who wrote what.

And don't use HTML, so no <quote>-tags.

Most of these, by now age old, formatting conventions would be taken
care of if you used a dedicated news client for reading newsgroups,
and not Google Groups, which, as a simple web interface, is not as
full featured. Dedicated newsreaders include Outlook, Outlook Express,
XNews, Agent and Thunderbird (and many others).

/L
 
R

Random

HTML-JSClub said:
o....k..... i dont remember quoting anything. And now I have a
question: in switch statements can i have it like:
or does it have to be a string or number?

Isn't it easier to try it and find out, rather than asking a dour bunch
of passive-aggressive scripters who are more likely to harp on the form
of your message than give you a meaningful response?

I promise it won't fry your motherboard, though it may insult your
mother.
 
R

Randy Webb

HTML-JSClub said:
o....k..... i dont remember quoting anything. And now I have a
question: in switch statements can i have it like:


or does it have to be a string or number?

Its easy enough to test. But yes, you can reference variables in your
case statement.
 
R

Richard Cornford

Random said:
Isn't it easier to try it and find out,

Trying things is often good, but so is looking at the documentation
(specifically the algorithms in ECMA 262).
rather than asking a dour bunch of passive-aggressive
scripters who are more likely to harp on the form of
your message than give you a meaningful response?
<snip>

'passive-aggressive' is an interesting label. It is impossible for the
recipient to object to it, or ignore, it without seeming to confirm the
diagnosis; useful when you have nothing but rhetoric to throw at an
argument.

The deal is; the posting conventions (including posting minimal trimmed
quotes of preceding messages, properly attributed, to provide a context
for responses) are for the benefit of the reader. In a one-to-many
communication medium like Usenet the convenience of the reader is
paramount as they significantly outnumber the author, and in most cases
the reader is the person who may be providing the answer, so it is
expedient to pander to their convenience.

Experienced participants in newsgroups don't like having to back-track
through threads to re-assemble the context of messages, or scroll
through yards of needlessly quoted material to see if there happens to
be a comment following it (and top-posting is the main cause of that).
But (not so) coincidentally it is the experienced participants who have
seen it all and know the answers to the questions asked. The upshot is
that the more experienced, and so likely more knowledgeable,
participants in the group are in a position to reduce the amount of
their time that is wasted by not answering the questions of people who
will not follow the Usenet posting conventions (or not assisting the
people who are answering questions but could benefit form a better
understanding), by not responding to their questions (or, in extremes,
killfileing them).

Obviously it is a bit unfair to dismiss people nothing more than what is
probably just ignorance of the conventions that they should be
following. So we provide a FAQ, which includes and outline of the
conventions, a reference to a detailed explanation, and a warning of the
consequences of ignoring them. One of the Usenet conventions is the
people wishing to participate in technical newsgroups that provide a FAQ
should read the FAQ prior to posting, but there is an obvious catch-22
in that for those initially ignorant of the conventions.

On the other hand people who need to be spoon-feed all of their
information, who cannot research anything and find out for themselves,
don't tend to be very interesting to talk to. So the normal practice is
to, more or less politely, initially refer people to the FAQ, suggesting
that they read it (and the resources that it refers to). And then to
make comments about the particular aspects of posting style in which
they are deficient. These represent the hints that a worthwhile
individual will pick up on. If they haven't picked up on them after a
couple of attempts then they are probably best dismissed form thought,
though some more charitable contributors may occasionally make the
effort of providing an additional detailed explanation of the
conventions (but doing that for everyone is not a realistic
expectation).

I notice that you got the idea quite quickly. One advisory comment and a
little observation and you are very close to producing perfectly formed
newsgroup postings, and that with the significant drawback for posting
from a poor example of a web interface instead of a newsreader. Just fix
that miss-attribution in your quote markers (the '> >', where it should
have just been '>'), and maybe use a clearer indicator of your edits,
and you will be 100%.

Richard.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top