#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Italy
    Posts
    25
    Rep Power
    0

    Question <SELECT>: onchange for already selected item


    I have a listbox (<SELECT...>). When the user selects one of the items, i want to set the focus elsewhere.
    I tried the onchanghe event but of course it doesn't fire if the selected item is the one which was already selected.
    I tried onclick and onmouseup events as well, but in IE they don't help because they fire when the user clicks the listbox to make the list drop down, and - at that stage - setting the focus away obviously makes the list disappear before the user can choose an item.

    What i'd need would be just like the onchange event but it should fire regardless of whether the selected item was already selected or not.

    BTW the whole problem is just setting the focus somewhere after the user has selected an item in the listbox.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    76
    Rep Power
    16
    how about this:

    <select onmouseup="if (++count==2) this.form.elements[n].focus()" onfocus="count=0" onchange="this.form.elements[n].focus()">

    the [n] here should point to some other element in the form, it might look better if "this.blur()" is used instead, but somehow it won't blur under my IE6/Win98 (NS7 is fine though).

    the drawback is, if one clicks to pull down the list but clicks somewhere else to collapse the list, the onmouseup won't fire so that the next time it clicks to pull down the list, the list would collapse right away.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Italy
    Posts
    25
    Rep Power
    0
    Good solution, thanks!
    The drawback you mention is actual, but it's much better than nothing. I'll have to check with the boss to see whether we should adopt this solution.
    If we (he) will decide to try to improve on this and we (i) will succeed in doing this, i'll post here the results.

    BTW and OT, this is definitely what is called a sick problem.

IMN logo majestic logo threadwatch logo seochat tools logo