Results 1 to 12 of 12
  1. #1
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript- Going thorough images in a page

    Hi,


    I'm rather new at Javascript, so this might be an elementary question.

    What I would like to do I would do in VBA something like:

    For each control in (thisform).controls
    if typeof(control) is Textbox then
    control.visible = flase
    end if
    next

    On the page, I would like to make each table (or perhaps each DIV tag or whatever) invisible, and then to make a single element (the name passed in to the routine) visible.

    It's a generic routine, so I want to use it for a number of different pages, with varying numbers of tables.

    ANy ideas?

    TIA

    Geoff
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  2. #2
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Javascript- Going thorough images in a page

    Can't help directly, but you may pick up a clue or two at The JavaScript Source

  3. #3
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Javascript- Going thorough images in a page

    Leif,

    Thanks for the reply.

    I've found the Javascript to be a very useful resource when I want to know how to do a specific job. However, I found it difficult to try to find what I wanted to do here, as I was after a technique which I couldn't relate to a specific job. For instance, If I wanted to find how to create a pop-up menu, I can do it easily, but on "objects in a collection" I couldn't find an answer easily.

    I found the answer isntead through the Microsoft Dynamic HTML reference http://msdn.microsoft.com/workshop/author/...e/dhtmlrefs.asp under collections.

    The resulting code I came up with looks like:
    <pre>var coll = document.all.tags("div");
    if (coll!=null){
    for (j=0; j<coll.length; j++) {
    (coll [j].innerHTML="")}
    }
    </pre>


    Geoff
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Javascript- Going thorough images in a page

    That site looks interesting, but I'm wondering why Pure JavaScript is not listed as a recommended book. I was thing of buying the book.

  5. #5
    navir
    Guest

    Re: Javascript- Going thorough images in a page

    As I'm sure Geoff knows, the "all" collection (document.all) and the "innerHTML" property (coll [j].innerHTML), are IE-specific. Therefore, his example JavaScript will throw an error with Netscape.

  6. #6
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Javascript- Going thorough images in a page

    navir,

    I didn't know that- it's worth noting. It doesn't matter to me now, as I'm designing for an IE intranet, but it may in the future.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  7. #7
    navir
    Guest

    Re: Javascript- Going thorough images in a page

    Hi, Howard:

    There are so many good JavaScript books and websites, it's difficult to pick the "best". Before I buy a book, I often do the following:

    I think of a problem I had difficulty solving, then look through several books to see how they handle that problem. I'll tend to pick the book that has the best explanation of this problem.

    In your case, you might check a dozen or so books and see how they handle stepping through collections.

    If you do find a dynamite book or website, let us know. Better yet, write a book or website review, post it on the internet, and give us the URL.

    Good luck.
    Ivan

  8. #8
    Silver Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles, California, USA
    Posts
    1,734
    Thanks
    0
    Thanked 3 Times in 1 Post

    Re: Javascript- Going thorough images in a page

    And, better even than that, post them on our new Books board. [img]/w3timages/icons/grin.gif[/img]
    <IMG SRC=http://www.wopr.com/w3tuserpics/Eileen_sig.gif>

  9. #9
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Javascript- Going thorough images in a page

    A books board, great!
    Wow, something that I cannot complain about!
    Hmmm, that makes me unhappy.

  10. #10
    Silver Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles, California, USA
    Posts
    1,734
    Thanks
    0
    Thanked 3 Times in 1 Post

    Re: Javascript- Going thorough images in a page

    [img]/w3timages/icons/laugh.gif[/img][img]/w3timages/icons/laugh.gif[/img][img]/w3timages/icons/laugh.gif[/img]
    <IMG SRC=http://www.wopr.com/w3tuserpics/Eileen_sig.gif>

  11. #11
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Javascript- Going thorough images in a page

    Well, I made the mistake of buying the Pure Javascript book. So far, I've only read the first 40, or so, pages.

    The book has several fundamental errors, including not properly explaining bitwise and logical operations.

    In addition, it calls E "Euler's constant". E is not Euler's constant, rather it is the base for natural logarithms.

    I'll continue reading the introductory portion (about 160 pages), but the fundamental errors I mention above give me little faith in the book.

  12. #12
    navir
    Guest

    Re: Javascript- Going thorough images in a page

    Hi, Howard:

    Thanks for the information about errors in "Pure JavaScript".

    Like software, technical books are rushed to print with more attention to presentation than content. I have several books on XML, and XML-related subjects, where the authors do not distinguish between HTML (a SGML language), and XML (a syntax for creating languages). I've started a list of references -- including Internet dictionaries and online courses -- that continue to refer to XML as a subset of SGML. (It's an intersection.)

    It's especially disturbing when code examples are mis-printed. Just yesterday I saw the DOCTYPE for XHTML printed incorrectly in a beginner's book on XHTML. (The closing angle bracket was omitted.) I doubt a beginner will discover this error before spending a lot of time trying to figure out why their document won't validate.

    Just for the record, I find myself using Danny Goodman's JavaScript Bible more frequently than other JavaScript books, but it has the worst index of any book I've ever read, and is decidedly tilted toward Netscape.

    Let us know how the rest of the book comes out, and thanks again for the information.

    Regards,
    Ivan

    P.S. After you get a chance to read this, I'm moving this information to the Books forum.

Posting Permissions

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