Refrencing Images

Discussion in 'Javascript' started by HTML-JSClub, May 22, 2005.

  1. HTML-JSClub

    HTML-JSClub Guest

    Anyone know how to refrence images? like GetElementByID except for
    images. I alread tried ...ByID ...ByName ...ByValue GetImageBy[previous
    ones].
     
    HTML-JSClub, May 22, 2005
    #1
    1. Advertising

  2. HTML-JSClub

    Random Guest

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

    document.images[0] === document.images[ 'foo' ] ===
    document.getElementById( 'foo' );
     
    Random, May 22, 2005
    #2
    1. Advertising

  3. On 22/05/2005 06:50, Random wrote:

    > <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

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.
     
    Michael Winter, May 22, 2005
    #3
  4. HTML-JSClub

    Random Guest

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

    or, rather,

    hands[ 'right' ].add( new Thumb( { direction: 'up' } ) );
     
    Random, May 22, 2005
    #4
  5. HTML-JSClub

    HTML-JSClub Guest

    Ok thx, i'll try them as soon as i can
     
    HTML-JSClub, May 23, 2005
    #5
  6. HTML-JSClub

    HTML-JSClub Guest

    i'm wondering, can i put in stead of a # in /document.images[0]/, can i
    put a variable /document.images[myimg]/?
     
    HTML-JSClub, May 24, 2005
    #6
  7. HTML-JSClub

    HTML-JSClub Guest

    never mind that, new problem: why isn't this working?

    > document.images[imgfile] === document.images[currX] ===

    document.getElementById(currX).src="man.jpg";
     
    HTML-JSClub, May 24, 2005
    #7
  8. HTML-JSClub

    HTML-JSClub Guest

    LOL, i keep solving my own problems (needed 3 ===) thx for all your
    help Micheal , "Random"
     
    HTML-JSClub, May 24, 2005
    #8
  9. HTML-JSClub

    Randy Webb Guest

    HTML-JSClub wrote:

    > 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?
     
    Randy Webb, May 24, 2005
    #9
  10. HTML-JSClub

    HTML-JSClub Guest

    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
     
    HTML-JSClub, May 24, 2005
    #10
  11. On 24/05/2005 06:02, HTML-JSClub wrote:

    > 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';

    In an earlier post where Random wrote:

    > <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

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.
     
    Michael Winter, May 24, 2005
    #11
  12. HTML-JSClub

    Randy Webb Guest

    HTML-JSClub wrote:

    > 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?
     
    Randy Webb, May 24, 2005
    #12
  13. HTML-JSClub

    HTML-JSClub Guest

    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.
     
    HTML-JSClub, May 25, 2005
    #13
  14. HTML-JSClub wrote:
    > Randy Webb wrote:
    >>HTML-JSClub wrote:
    >>> Randy Webb wrote:

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

    <snip>
    >>>sry for the confusion

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

    <snip>
    > ... if i'm still missing the point than i have
    > NOOOOOO idea what you're talking about.


    Concentrate on the words "how to quote".

    Richard.
     
    Richard Cornford, May 25, 2005
    #14
  15. HTML-JSClub

    HTML-JSClub Guest

    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?
     
    HTML-JSClub, May 25, 2005
    #15
  16. HTML-JSClub

    HTML-JSClub Guest

    ooooooooooohh!!! OK i get it now. When quoting someone i add <quote>
    and </quote> around it. right?
     
    HTML-JSClub, May 25, 2005
    #16
  17. "HTML-JSClub" <> writes:

    > 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
    --
    Lasse Reichstein Nielsen -
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
    'Faith without judgement merely degrades the spirit divine.'
     
    Lasse Reichstein Nielsen, May 25, 2005
    #17
  18. HTML-JSClub

    Random Guest

    HTML-JSClub wrote:
    > 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?


    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.
     
    Random, May 25, 2005
    #18
  19. HTML-JSClub

    Randy Webb Guest

    HTML-JSClub wrote:

    > 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?


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

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
     
    Randy Webb, May 25, 2005
    #19
  20. Random wrote:
    > HTML-JSClub wrote:
    >> 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?

    >
    > 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.
     
    Richard Cornford, May 26, 2005
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TmF0aGFuVg==?=

    Refrencing a class library

    =?Utf-8?B?TmF0aGFuVg==?=, Oct 2, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    370
    =?Utf-8?B?TmF0aGFuVg==?=
    Oct 2, 2004
  2. Guest
    Replies:
    4
    Views:
    923
    Eliyahu Goldin
    Jan 4, 2005
  3. Luis Esteban Valencia Muñoz
    Replies:
    0
    Views:
    801
    Luis Esteban Valencia Muñoz
    Jun 3, 2005
  4. Replies:
    2
    Views:
    509
  5. ferhat

    popup on same page refrencing itself

    ferhat, Jun 6, 2006, in forum: Javascript
    Replies:
    2
    Views:
    110
Loading...

Share This Page