Results 1 to 3 of 3

Thread: Reference an object

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    Newcastle,UK
    Posts
    66

    Reference an object

    Hi

    Can anyone help me with something that is confusing me...

    I know that in javascript you can reference a HTML object by using:

    document.all['blah'] etc

    but it i want to dynamically reference the object for example

    var strValue = 'divInfo';

    document.all[strValue]

    I am unable to do this

    Can anyone suggest why this might be the case?

    Thanks in advance

    Sarah

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    It should work. Are you sure the element exists?

    But document.all is IE-only!
    document.getElementById(<id>) is better.
    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.

  3. #3
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    yes, use getElementById(). if it still esn't working, please tell us what the rror is and what browser you get the error with?
    Have I helped you? Please Rate my posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width