473,396 Members | 1,995 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

listbox with locked lines

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>

Jan 7 '06 #1
6 3080
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
Jan 7 '06 #2
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
Jan 7 '06 #3
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
Jan 7 '06 #4
On 2006-01-06, Mokka <pr**********@gmail.com> wrote:
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"

<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>

HTH.

Bye.
Jasen
Jan 8 '06 #5
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
Jan 8 '06 #6
Jasen Betts wrote:
On 2006-01-06, Mokka <pr**********@gmail.com> 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
Jan 12 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: R.Wieser | last post by:
Hello All, I'm trying to get a "Virtual Listbox" to work. I've currently got a form, and used CreateWindowExA to create a ListBox with the LBS_OWNERDRAWFIXED and LBS_NODATA flags on it. I've...
8
by: Andy Weinmann | last post by:
I am trying to make a form in which i can view the ihe information for companies. I have a combobox which contains all of the work categories that the companies fit into. I have gotten the...
5
by: ColinWard | last post by:
Is there any way to skip lines programatically within a listbox as there is in a textbox? I have a listbox on a form which gets populated with the attachments I want to send with an e-mail but they...
2
by: alanb | last post by:
This is driving me NUTS. I have a listbox bound to a datasource and it all works fine until I start deleting items from the class collection. The frustrating thing is that there is no pattern to...
0
by: raypjr | last post by:
Hi everyone. I'm new here and hope I can get a little advice on how to list my array into a ListBox. I have my structure and array of structures. I need help with a For Loop that will list the...
2
by: raypjr | last post by:
Hi everyone. I'm new here and hope I can get a little advice on how to list my array into a ListBox. I have my structure and array of structures. I need help with a For Loop that will list the...
4
by: dgardner | last post by:
I have several listboxes on a form. When the form opens, they are all disabled and, as a result, are dimmed. All that is except for one. One of the listboxes is disabled but does not dim...
0
by: LostInMd | last post by:
Hi All, I've got an owner drawn listBox where I draw and measure the items that I add to the listBox. For example, I have a listBox that can only display 10 characters on each horizontal line. ...
11
by: Mai Phuong | last post by:
Hi all, I have a page of aspx and a listbox. I want to format font for 3 last lines of my listbox with Bold Style by code. Notice that my lisbox has more than 3 lines, and I don't know exactly...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.