Solved

I need an onBlur event for  some kind of container to run a validation

Posted on 2007-11-30
7
265 Views
Last Modified: 2013-11-19
I have two sets of  radio buttons in a div. One of the option from each is "protect with password".  If the user selected the "password" option in any of these sets, I want to call an onBlur (with the function to enter password) but only once when they leave the div event if possible.  The problem is that only form objects support onBlur event. I use ajax to update my db so I really don't want to call ajax every time someone clicks the radio buttons.
any help is much appreciated
0
Comment
Question by:JoeUS
  • 4
  • 3
7 Comments
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 20384082
JoeUS,

What do you mean leave the "div event"?  As you pointed out that element (and other non-form elements) does not have an onblur event.  The reason is it doesn't have a focus event either.  So how to you see firing this?  What interaction by the user on the page should trigger this?  We need to find something along those lines to have a chance at finding a "substitute" for the onblur event.

Let me know if you have any questions or need more information.

b0lsc0tt
0
 

Author Comment

by:JoeUS
ID: 20384587
div event was a typo. Sorry for that.
What I am doing right now is I use check boxes and  check for change at onBlur for each of them. I call ajax if anything changed and also request password if there was none set yet. I also call a confirm for the password and if validation fails on them, then move focus back to the proper object accordingly. Now, focus works quite differently in FF than in IE. This is why I would like to call for password, validation and ajax after I am done with the radios or check boxes.
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 20387072
I don't really understand what you mean.  What is the problem now and is it just browser related?

What needs focus?  When should that happen?  Keep in mind it should be related to an event or script.  You mentioned password, radios, etc but which element has focus and where should the focus go?  What works and when does it fail?  Maybe the explanation above just needs to be reworded or it might just be that it is soo late but it just seems unclear.

If I understand you right you may want to put focus back on some element.  If that is true then you will need a global variable to keep track of where the focus "was."  If I am right and you need script as an example then I can provide it.  This is just a guess though. :)

bol
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:JoeUS
ID: 20421073
"If I understand you right you may want to put focus back on some element.  If that is true then you will need a global variable to keep track of where the focus "was.""

Yes it seems like I will need a global to track the focus, but not only to put focus back on some objects but to call some functions. What I want to do is to reduce the number of calls I make back to the server with updates (asynchronous). Ideally I would know, which object  I had the focus on onBlur and make the call accordingly. Unfortunately, I do not know how to track the focus effectively to tell, which object it was on or is explicitly.
0
 
LVL 54

Accepted Solution

by:
b0lsc0tt earned 500 total points
ID: 20424616
I have reread the comments and info here but I just don't have details to make a specific suggestion for you.  All the things you mentioned in the last comment are just too general for me to know how to suggest you implement a "global" variable.

I can tell you what I mean by that and maybe that is enough.  In the section of your html where you have the script (hopefully the head part of your page) you would declare the variables.  They would not be in a function, etc so they will be "global" and last as long as the page is there.  A simple example of this would be ...

<script type="text/javascript">
var w = null;

That is one I have used for popup windows before.  I end up assigning the new window to w so I can later tell if it exists, is closed, etc.

If you need help using this idea then please provide info.  There is no "canned" way to do what you want and it needs to be "made" for your page and situation.  That doesn't mean it can't be done or the code is complex but just means there isn't one answer.  Let me know if you have a question about this or anything I have said.

bol
0
 

Author Comment

by:JoeUS
ID: 20472119
Thank you b0lsc0tt

This short discussion did help me to figure out what to do about minimizing callbacks to the server. First of all, I decided to fire the ajax for (only) the db updates at on click for the radios and onblur for the other elements. I also use JS to take care of the object updates in the current html. I fire ajax when the objects were correctly updated, so to keep them in sink with the db. I also make sure that the objects are initiated and the values are being reloaded on page load. It does work and the user experience is great! No IE page refresh on every clicks and coughs.

Thanks again for the help
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 20472657
Your welcome!  I'm glad I could help.  Thanks for the grade, the points and the fun question.

bol
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question