SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Sep 2004
    Location
    Denver
    Posts
    385
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hide option items in a select box

    Hello, I have a list box <select></select> that contains several itmes <options> and I also have a Delete button when clicked, it should "remove" the selected item from the list (by firing the RemovefromList function shown below). I don't really want to remove the selected item from the list box, rather I was wondering if there is a way that I can set a hidden property on the selected item (so it looks like it was deleted to the end user)
    any thoughts on this are appreciated. Thanks.
    PHP Code:
    function RemoveFromList()
    {
        if (
    CtrlName != null)
        {
            var 
    Ele CtrlName;
            
            if(
    Ele.selectedIndex==-1)
            {
                
    alert("Select an Item To Remove");
                
    //f.lstCurItem.focus();
            
    }
            else
            {
                for (var 
    i=0i<Ele.lengthi++)
                { 
                    if (
    Ele.options[i].selected)
                    {
                    
    //instead of using null below, I need a hide or something
                        //Ele.options[i] = null;
                    
    }
                }
            }
        }


  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,495
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    change the color to the background color?

    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd"
    >

    <
    html>

    <
    head>
      <
    title></title>
    </
    head>

    <
    body>
    <
    select id=sel size="1" style="color:white;" >
    <
    option value="one">one</option>
    <
    option value="one">Two</option>
    <
    option value="one">Three</option>
    <
    option value="one">Four</option>
    </
    select>
    <
    script language="JavaScript" type="text/javascript">
    <!--
    document.getElementById('sel').options[0].style.color='red';
    document.getElementById('sel').options[1].style.color='white';
    document.getElementById('sel').options[2].style.color='green';
    document.getElementById('sel').options[3].style.color='blue';
    //-->
    </script>
    </body>

    </html> 
    tested IE6 Moz FF NS7

  3. #3
    SitePoint Addict
    Join Date
    Sep 2004
    Location
    Denver
    Posts
    385
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    doesn't sound like a bad idea... thanks vwphillips


Bookmarks

Posting Permissions

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