Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
  1. #1
    Junior Member
    Join Date
    Oct 2003
    Posts
    2
    Member #
    3404
    I have a problem that I can't seem to get around.

    I'm trying to create a list on our company's Intranet that has your typical Windows Explorer "+" and "-" signs to expand and collapse rows that contain data.

    All is working fine until I try to use a looping contruct to repeat the form the data sits in. The loop is based on the results from a database query ... so it could return 1 or many records that need to be displayed.

    The form name gets repeated for every iteration of the loop, so I've made the form name a variable that gets incremented each time and therefore each "unique" form can be accessed individually by that name.

    Now the problem comes in when I try reference the specific form (actually the image inside it) in JaveScript as "document.form_name.mypic.src" because it thinks form_name is the name of my form istead of the value of form_name.

    I thought the eval command would work, but it returns the URL of the image I'm clicking.

    Please help .... let me know if you need any more info.

  2.  

  3. #2
    Senior Member skrlin's Avatar
    Join Date
    Apr 2003
    Location
    Illinois
    Posts
    562
    Member #
    1063
    Instead of trying to access the individual form through the form's name attribute, try giving the forms the id attrib and give it the same value as the name attrib.

    EXAMPLE:
    Code:
    <!-- instead of using this -->
    <form name="form1">
    <!-- form code here -->
    </form>
    
    <!-- and accessing it through this -->
    <script>
    function menuExpand(field, form_name) 
    {
    someVar = document.form_name.mypic.src;
    // ....
    }
    </script>
    Try this:
    Code:
    <form name="form1" id="form1">
    <!-- form code here -->
    </form>
    
    <!-- and access it through this -->
    <script>
    function menuExpand(field, form_name) 
    {
    someVar = document.getElementById(form_name).mypic.src;
    // ....
    }
    </script>
    - Brian

  4. #3
    Junior Member
    Join Date
    Oct 2003
    Posts
    2
    Member #
    3404
    Thanks

    Thanks alot .... what a legend! It works.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 07:44 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2020 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com