listbox with locked lines

Discussion in 'Javascript' started by Mokka, Jan 6, 2006.

  1. Mokka

    Mokka Guest

    Hi,

    I have this listbox and I would like to lock some of the lines so that
    the user can't select them. It's the 2 main areas "2798 Mokka"
    and "3892 Juice" I don't won't the user to be able to select.
    basically alle the lines that has a numer in front of the title needs
    to be locked.

    Please help! :)

    <select name="ListBox" size="5" multiple="multiple" id="ListBox">

    <option>2798 Mokka</option>
    <option>indian blend</option>
    <option>arabian blend</option>
    <option>3892 Juice</option>
    <option>Orange juice</option>
    <option>cucumber juice</option>

    </select>
     
    Mokka, Jan 6, 2006
    #1
    1. Advertising

  2. Mokka wrote:

    > I have this listbox and I would like to lock some of the lines so that
    > the user can't select them. It's the 2 main areas "2798 Mokka"
    > and "3892 Juice" I don't won't the user to be able to select.
    > basically alle the lines that has a numer in front of the title needs
    > to be locked.


    Use the `optgroup' element instead.

    > [...]
    > <select name="ListBox" size="5" multiple="multiple" id="ListBox">
    >
    > <option>2798 Mokka</option>
    > <option>indian blend</option>
    > <option>arabian blend</option>
    > <option>3892 Juice</option>
    > <option>Orange juice</option>
    > <option>cucumber juice</option>
    >
    > </select>


    <select name="ListBox" size="5" multiple="multiple">
    <optgroup label="2798 Mokka">
    <option>indian blend</option>
    <option>arabian blend</option>
    </optgroup>
    <optgroup label="3892 Juice">
    <option>Orange juice</option>
    <option>cucumber juice</option>
    </optgroup>
    </select>


    PointedEars
     
    Thomas 'PointedEars' Lahn, Jan 7, 2006
    #2
    1. Advertising

  3. Mokka

    mick white Guest

    Thomas 'PointedEars' Lahn wrote:


    > <select name="ListBox" size="5" multiple="multiple">
    > <optgroup label="2798 Mokka">
    > <option>indian blend</option>
    > <option>arabian blend</option>
    > </optgroup>
    > <optgroup label="3892 Juice">
    > <option>Orange juice</option>
    > <option>cucumber juice</option>
    > </optgroup>
    > </select>
    >
    >


    Or:
    <script type="text/javascript">
    function getCategory(opt){
    return opt.parentNode.label;
    }
    </script>
    <form action="">
    <select name="listBox" size="6"
    onchange="this.form.x.value=getCategory(this[this.selectedIndex]);">
    <optgroup label="2798 Mokka">
    <option>indian blend</option>
    <option>arabian blend</option>
    </optgroup>
    <optgroup label="3892 Juice">
    <option>orange juice</option>
    <option>cucumber juice</option>
    </optgroup>
    </select>
    <input name="x" type="text" readonly value="">
    </form>
    Mick
     
    mick white, Jan 7, 2006
    #3
  4. mick white wrote:

    > Thomas 'PointedEars' Lahn wrote:
    >> <select name="ListBox" size="5" multiple="multiple">
    >> <optgroup label="2798 Mokka">
    >> <option>indian blend</option>
    >> <option>arabian blend</option>
    >> </optgroup>
    >> <optgroup label="3892 Juice">
    >> <option>Orange juice</option>
    >> <option>cucumber juice</option>
    >> </optgroup>
    >> </select>

    >
    > Or:


    Or?

    > <script type="text/javascript">
    > function getCategory(opt){
    > return opt.parentNode.label;
    > }
    > </script>
    > <form action="">
    > <select name="listBox" size="6"
    > onchange="this.form.x.value=getCategory(this[this.selectedIndex]);">
    > <optgroup label="2798 Mokka">
    > <option>indian blend</option>
    > <option>arabian blend</option>
    > </optgroup>
    > <optgroup label="3892 Juice">
    > <option>orange juice</option>
    > <option>cucumber juice</option>
    > </optgroup>
    > </select>
    > <input name="x" type="text" readonly value="">
    > </form>


    That is an interesting solution, yet not one that address the OP's wish:

    | It's the 2 main areas "2798 Mokka" and "3892 Juice" I don't won't the
    | user to be able to select.

    And it introduces a dependency to client-side scripting for no obvious
    reason, so I really wonder why you posted it in the first place.


    PointedEars
     
    Thomas 'PointedEars' Lahn, Jan 7, 2006
    #4
  5. Mokka

    mick white Guest

    Thomas 'PointedEars' Lahn wrote:
    > mick white wrote:

    [...]
    >
    >
    > That is an interesting solution, yet not one that address the OP's wish:
    >
    > | It's the 2 main areas "2798 Mokka" and "3892 Juice" I don't won't the
    > | user to be able to select.
    >
    > And it introduces a dependency to client-side scripting for no obvious
    > reason, so I really wonder why you posted it in the first place.
    >
    >


    Just free flowing thoughts put to paper...
    Cheers.
    Mick
     
    mick white, Jan 8, 2006
    #5
  6. Jasen Betts wrote:

    > On 2006-01-06, Mokka <> wrote:
    >> I have this listbox and I would like to lock some of the lines so that
    >> the user can't select them. It's the 2 main areas "2798 Mokka"

    >
    > <select name="ListBox" size="5" multiple="multiple" id="ListBox">
    >
    > <option disabled="disabled" >2798 Mokka</option>
    > <option>indian blend</option>
    > <option>arabian blend</option>
    > <option disabled="disabled" >3892 Juice</option>
    > <option>Orange juice</option>
    > <option>cucumber juice</option>
    >
    > </select>


    In HTML, boolean attributes like `multiple' and `disabled' have no value,
    the above is X(HT)ML syntax. And there is no need for `disabled', since
    the `optgroup' element exists since HTML 4 as well as the `disabled'
    attribute does. In contrast, UAs not supporting the `disabled' attribute
    for some reason (such as HTML 3.2 support only), will allow to select the
    respective `option' element anyway.

    So this is not a viable solution.


    PointedEars
     
    Thomas 'PointedEars' Lahn, Jan 12, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. blenderdude
    Replies:
    0
    Views:
    1,154
    blenderdude
    Aug 3, 2003
  2. DC Gringo
    Replies:
    0
    Views:
    423
    DC Gringo
    Apr 6, 2004
  3. kent
    Replies:
    1
    Views:
    910
    Andrew de la Harpe
    May 3, 2004
  4. Simon Prince
    Replies:
    2
    Views:
    3,388
    =?Utf-8?B?TWljaGFlbCBUYXlsb3I=?=
    Oct 19, 2004
  5. Chris Kettenbach

    Listbox selection to populate another listbox?

    Chris Kettenbach, Jun 15, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    1,694
    Chris Kettenbach
    Jun 16, 2005
Loading...

Share This Page