Forum Moderators: open
The owner really likes this select box, although I think the list is kind of long for easy user scrolling. Nevertheless, it must stay. Repositioning it to a different location, like below the main page content, isn't an option.
So, I'm looking for a way to keep the select box displayed where it is, but to get it off the HTML page. Would an external javascript file be the best way to go? It's a bit messy because the pages are part of a complex shopping cart system and the list itself is generated by a call to an external function in another ASP file. Any other clever ideas?
I was on a site the other day and I was getting really upset because I couldn't work out how to get to the rest of the content. Then I saw this dumb dropdown! Think about it: I'm a very experienced user, I design websites for gods sake, and I got confused and almost left!
Nick
I think they might make sense if used in addition to a more traditional navigation system, as a "Quick Jump To..." style thingy. So you might use the traditional system to drill down through the site (e.g. North America > USA > New York State > Albany), but also have a drop-down list of, say, the 50 most popular cities as a short-cut. That kind of thing. It gives people a choice as to how they browse the site, and as long as they have clear instructions and labels (being careful, for example, to make sure they can distinguish easily between Washington State and Washington DC), and it doesn't clutter your pages up too much... why not do it?
I guess if you did some nifty server-side programming and juggling with cookies you could have a kind of a Most Recently Used list as a drop-down. I've never seen this being done, I only just got the idea typing this. It intrigues me, I might see if I can implement it in some way.
One possibility for the future -- maybe -- is <optgroup>. You can group <option>s together like this:
<select>
<optgroup label="Wines">
<option>Cabernet sauvignon</option>
<option>Pinot noir</option>
<option>Chardonnay</option>
</optgroup>
<optgroup label="Non-alcoholic">
<option>Coca-cola</option>
<option>7-Up</option>
</optgroup>
</select>
This is new in HTML 4.0, I believe. Those browsers that currently support it render the labels as labels, so this appears something like this:
Wines
Cabernet Sauvignon
Pinot Noir
Chardonnay
Non-alcoholic
Coca-Cola
7-Up
It's possible that some future browsers may choose to render these as cascading menus, which would be an intersting solution to the problem we were originally discussing here. You can't nest <optgroup>s, however... which may be a blessing.
"American Airlines' approach reduces the vast majority of site features to a set of pull-down menus that are difficult to navigate: Users can never see the full set of features ... becuase they can pop up only a single menu item at a time. And many of the menus are so long that they require scrolling, menaing that users can't even view the entire list of options in a menu at a single glance. Thus, American Airlines' approach works only if the two highlighted features, in fact, account for almost all use of the site."
J.N., Designing Web Usability, p. 171.
Tom
So, I'm looking for a way to keep the select box displayed where it is, but to get it off the HTML page. Would an external javascript file be the best way to go? It's a bit messy because the pages are part of a complex shopping cart system and the list itself is generated by a call to an external function in another ASP file. Any other clever ideas?
Mmm, well, I'm not sure exactly what your goal is here. Why do you want to move the select element off of the asp/html? Is it because you are having dozens and dozens of option tags in the mark up? Or when you say "get it [the select box] off the HTML page" are you talking moving the displayed select element off of the page (and into another window/frame or something)?
In some of the intranet apps that I'm currently working on what we do is put a blank select element with an id in the page where the list is supposed to go and then generate the options on the list dynamically with javascript. So, for instance, with a select element with an id="listSelect" we can loop through some imported XML data and populate a list of names with unique IDs like so:
for(var i = 0; i < objNodeList.length; i++){
objNode = objNodeList.item(i);
objSub = objNode.selectSingleNode("name");
if(objSub)strName = objSub.text;
objSub = objNode.selectSingleNode("id");
if(objSub)strID = objSub.text;
opt = new Option(strName,strID);
document.getElementById('listSelect').options[i]=opt;
} We have also done similar things with XSLT for XML data, and it seems to work well.
But my comments are probably useless because I'm not sure what the real goal is here.
Here's the problem: If I look at the HTML (as a spider would), I've got big pile of options that appear above my main text. I.e., if my page is about "Blue Widgets", I've got my title "Buy Blue Widgets Cheap", my metas, etc., but before I get to my text that describes our Blue Widget product line, a spider encounters a long list of "Plastic Widgets", "Fuzzy Gizmos", etc., I'm thinking instead about inserting it via an external javascript file that robots would ignore. This would lighten up the page size and get rid of the distracting and lengthy list at the same time. At least, that's my current thought... I haven't sorted out how the js will interact with the dynamically generated option list yet. I suppose another way to handle it would be to set the generated content up as js in the page inself - that wouldn't lighten the page, but the spiders might be more inclined to ignore it. Conventional wisdom says, though, that a bunch of js at the beginning of the page is a bad thing...
Of course, a spider won't have any links at all to follow through your site if you generate all of your links dynamically like this ...
I don't think the Option Group approach would work for this particular site (it's mostly a long alphabetical list with no easy way to categorize the items), but that is an intriguing idea - what do older browsers do, newboss, ignore the optgroup tag?
Thanks for the suggestions, everyone.
what do older browsers do, newboss, ignore the optgroup tag?
Browsers are required to ignore any tag they don't understand; that ensures at least some measure of backwards compatibility. (It also makes some typos pretty hard to find, which is one reason we need validators.) Older browsers will give you a standard list of options without the groupings and without inserting any extra labels etc.
<optgroup> may be one of the most underused tags in HTML. People still use ordinary <option>s to divide drop-down lists into categories with extra JavaScript widgets to make sure they don't get submitted when <optgroup> labels do the job so much better.
P.S. I think this is the 7th bulletin board I've joined where people call me "newboss". Why is this?