2010-11-30 70 views
0

我在公司页面有10个文本框。其中5个常用于位置页面。 我的目标是询问用户他是否想更新公司页面甚至是位置页面。如果用户更改了位置页面中常见的5个文本框 ,则弹出窗口显示为“您是否要更新位置页面”,或者如果用户更改了其他5,则弹出显示 “您要保存吗?不同的弹出文本框更改?

我们如何确定哪些文本框发生了变化以及应该显示哪个弹出窗口?有人能帮助我吗?感谢所有:)

回答

0

其中一种方法是:

  1. 中安装jQuery(只是为了更容易获得控制)
  2. 指定一个类名像class='common'第一组文本框的
  3. 指定其他的className像class='other'为“公地”
  4. 手柄onblur事件的第二组文本框:

    $(":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); 
    }); 
    
  5. 手柄onblur事件为 '其他':

    $(":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); 
    }); 
    

有一个想法?

+0

你真的是天才。谢谢! :) – Ram 2010-12-01 16:26:30