We help IT Professionals succeed at work.
Get Started

Execute Javascript on focus and lostfocus of Listbox

allanmark
allanmark asked
on
10,232 Views
Last Modified: 2012-06-27
Greetings all

I have the following scenario:

A listbox that display various titles, with details in a panel alongside. There are buttons to Insert, Edit, Save and Update (the database). I also have two booleans bRequireSave and bRequireUpdate to trap if the user attempts to leave the page while there is unsaved data.  When a record has been added/edited and is saved (to the dataset), focus returns to the listbox for further scrolling/whatever. If the user attempts to exit, he/she ar warned - as expected. My problem is this:- when the user scrolls down, they still receive the :unsaved data blah blah" message (if the save to the databse has been made, then I don't have this problem).

My thoughts were to introduce a 3rd boolean, bGenuineExit which would, when focus shifted away from the listbox, be set to True. The JScript would read something like if (bRequiredUpdate and bGenuineExit)  {blah blah ....} ").  

My problem(s)  -- I can't get the onfocus, lostfocus  or onblur to work for the listbox. I am also not sure if there is a better way to handle this?

WHAT SHOULD I BE DOING??


Inadvance, thanks!
Comment
Watch Question
Software Engineer
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 11 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE