www.webdeveloper.com
Results 1 to 3 of 3

Thread: Get list element name or value

  1. #1
    Join Date
    Oct 2009
    Posts
    4

    Get list element name or value

    Hello i have an html list:
    Code:
    <ul id="carrierList">
    <li class="carrierListElem" name="AmeriHealth Administrators" value="AmeriHealth Administrators">AmeriHealth Administrators</li>
    
    <li class="carrierListElem" name="Carefirst-Blue Cross Blue Shield" value="Carefirst-Blue Cross Blue Shield">Carefirst-Blue Cross Blue Shield</li>
    
    <li class="carrierListElem" name="3P ADMIN" value="3P ADMIN">3P ADMIN</li>
    </ul>
    and i want to get either the value or name using javascript and based of the value/name change the style to display:none;

    i currently am doing this:
    Code:
    carrierList = document.getElementById("carrierList");
    // get all list elements of the carrier list
    carriers = carrierList.getElementsByTagName("li");
    
    alert(carriers[0].name);
    alert(carriers[1].value);
    however the alert message just says "undefined"

    can anyone help me? i want to be able to get the contents of the li element into a string.

  2. #2
    Join Date
    Oct 2009
    Posts
    4
    Never mind "innerHTML" is all i needed to use

    doh!

  3. #3
    Join Date
    Oct 2009
    Location
    Tampa Florida
    Posts
    10
    Don't you just hate it when you have those doh moments in public.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles