Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > listbox with locked lines

Reply
Thread Tools

listbox with locked lines

 
 
Mokka
Guest
Posts: n/a
 
      01-06-2006
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>

 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      01-07-2006
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
 
Reply With Quote
 
 
 
 
mick white
Guest
Posts: n/a
 
      01-07-2006
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
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      01-07-2006
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
 
Reply With Quote
 
mick white
Guest
Posts: n/a
 
      01-08-2006
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
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      01-12-2006
Jasen Betts wrote:

> On 2006-01-06, Mokka <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Listbox selection to populate another listbox? Chris Kettenbach ASP .Net 3 06-16-2005 09:19 PM
Listbox item added with client scripts not submitting with ASP:Listbox Simon Prince ASP .Net 2 10-19-2004 04:11 PM
How do I move all items in a listbox to another listbox kent ASP .Net 1 05-03-2004 12:17 AM
click listbox and refresh another listbox DC Gringo ASP .Net 0 04-06-2004 02:13 AM
Re: now desparate! - 1st listbox contents disappears when 2nd listbox appears? blenderdude ASP .Net 0 08-03-2003 10:18 PM



Advertisments