Terri,
Here's some code to handle your first question. It disallows selection of any
item whose value begins with "xx".
Add this function to the <head> section:
function checkSelect(e) {
// Disallow selection of items whose value begins "xx"
for (var i=0; i < e.options.length; i++) {
if (e.options[i].selected && e.options[i].value.substr(0,2) == "xx") {
e.options[i].selected = false;
}
}
}
Note how the function is called, and the two values which begin "xx":
<select name="mySelect" multiple size="7" onchange="checkSelect(this)">
<option value="xxThomas">Thomas</option>
<option value="Edward">Edward</option>
<option value="xxGordon">Gordon</option>
<option value="Henry">Henry</option>
<option value="James">James</option>
<option value="Percy">Percy</option>
<option value="Toby">Toby</option>
</select>
Philosophically I am opposed to doing this, but I understand that requirements
trump philosophy.
-David
On Friday, June 29, 2001 6:15 PM, Terri Stocke [SMTP:[EMAIL PROTECTED]]
wrote:
> Hey all,
>
> I have a two-part question that I'm really hoping someone can answer.
>
> I have a multiple-select list that is populated from one table in my db. The
> list is constructed in such a way that there are main categories that each
> have their own subcategory. Some of those subcategories have their own
> subcategories. The main categories are all in uppercase, and the
> subcategories are indented, as appropriate, throughout the list.
>
> I don't want users to be able to select every item--I want them to have to
> select as far as they possibly can within the subcategories. So...
>
> QUESTION 1: Is there a way to disable selection ability on certain items
> within the select box (just don't allow it to be highlighted when clicked),
> and if so, how?
>
> QUESTION 2: How do I conditionally format the look of each of these menu
> items within this one select list? I have been successful in conditionally
> changing words to uppercase, or indenting, but I cannot get it to
> conditionally bold a word, change the font size, add a line break, etc. I've
> tried style sheets, but you have to actually specify the class in the <TD>
> tag, which won't work. I need to be able to optionally format the <OPTION>
> tags.
>
> I know a DHTML menu or a javascript would be better--that way I could just
> display the subcategories for selection as appropriate--but the customer
> really likes being able to see every possible category and subcategory in
> one box all at once.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists