Different popup for textbox change?
I have 10 textboxes in Company page. 5 of them are common in Location page. My goal is to ask user if he wants to update 开发者_JAVA技巧just company page or even location page. If the user changes 5 textboxes that are common in Location Page, the popup shows as "Do you want to update Location Page as well" or if the user changes the other 5, then popup shows "Do you want to save?"
How do we determine what textboxs are changed and which popup should be shown?? Could someone help me out. Thanks all :)
One of the methods is:
- install jquery (just for easier access to controls)
- assign a className like
class='common'
to the first set of textboxes - assign another className like
class='other'
to the second set of textboxes handle onblur event for 'commons':
$(":input.common").blur(function() { if ($(this).data("changed") && confirm("Do you want to update Location Page as well?")) { // TODO: perform update } }).keydown(function(e) { $(this).data("changed", true); }).focus(function(e) { $(this).data("changed", false); });
handle onblur event for 'others':
$(":input.other").blur(function() { if ($(this).data("changed") && confirm("Do you want to save?")) { // TODO: perform save } }).keydown(function(e) { $(this).data("changed", true); }).focus(function(e) { $(this).data("changed", false); });
Got an idea?
精彩评论