RE: Disallowing selectbox change

"Gale, David" <[email protected]> Thu, 20 Apr 2006 15:25:18 -0400
Newsgroups gmane.comp.web.dom.wdf
Message-ID <[email protected]>
Well, I'd prefer the second option (and it's a possibility I raise at
the end of my original post), as it ensures that the visible option
accurately reflects the currently active page.  I was hoping that there
was a cleaner cross-browser way to prevent an option from being
selected, but if there isn't, there isn't.

-David

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf
Of Ryan Hicks
Sent: Thursday, April 20, 2006 2:51 PM
To: [email protected]
Subject: RE: [wdf-dom] Disallowing selectbox change


David-

At first thought, is it possible to not submit when the same "PageN" is
selected?  That is, you would still allow the onchange event to fire,
but
when you're checking to see if a "Category" option is selected, also
check
to see if the same page is selected (this is likely the only option with
defaultSelected==true).  This will allow people to select a category
(nothing happens), then select their previous selection (nothing
happens)
then select a new page (submission).

Another thought would be to, when the "Category" option is selected,
revert
the select to the previous option.  Note that scripts do not trigger
events
unless you ask them to, so reselecting the previous selection should
avoid
your problem completely.

Apologies for splitting my infinitive there...

-ryan

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf
Of
Gale, David
Sent: Thursday, April 20, 2006 11:23 AM
To: [email protected]
Subject: [wdf-dom] Disallowing selectbox change

I'm working on a fairly standard drop-down select navigation widget; now
my user wants to add categories to the select, thusly:

-- Category1 --
Page1
Page2
Page3
-- Category2 --
Page4
Page5
Page6

When the page is loaded, the appropriate item is selected.  If a
different "PageN" option is selected, the onchange fires, redirecting
appropriately; if one of the Category option is picked, it doesn't
submit (easily done).  However, if a Category option is selected, it's
possible to then select the original page link, causing the page to
reload.

Is there any way in the onchange handler to disallow the change--so, if
the selected option has no value, the select box returns to the
previously selected option?  Firefox allows me to disable the Category
options entirely, which is nice (and avoids the issue), but IE doesn't.
I thought returning false might do the trick, as that works for form
onsubmits, but no dice.  The only other option I can think of is to
record where the select ought to be, and, if the user tries to pick
something invalid, force the selectedIndex back to the original, but
this feels somewhat kludgy.  Is there a better option I'm not aware of?

Thanks,
-David


Unsubscribe
[email protected]

List info
http://www.quirksmode.org/dom/list.html 
Yahoo! Groups Links



 




Unsubscribe
[email protected]

List info
http://www.quirksmode.org/dom/list.html 
Yahoo! Groups Links



 




Unsubscribe
[email protected]

List info
http://www.quirksmode.org/dom/list.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/wdf-dom/

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/