2012-02-19 105 views
2

在我的jsp页面中,我有一个文本框和两个组合框。当我在文本框中写入某些内容时,我的jsp页面中会发出警报。警报即将到来,因为“用户名已存在”,并在警告文本框自动刷新但两个组合框正在消失为什么?我找不到可能的原因,请帮忙吗?我在头部包含以下内容。警报的完整来源是here组合框在警报即将到来时消失

http://csscody.com/demo/wp-content/demo/popup/js/jquery.easing.1.3.js

http://csscody.com/demo/wp-content/demo/popup/js/alertbox.js

http://csscody.com/demo/wp-content/demo/popup/js/style.css

<html> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
    <title>JSP Page</title> 
    <SCRIPT type="text/javascript" src="js/jquery.min.js"></SCRIPT> 
<SCRIPT type="text/javascript" src="js/jquery.easing.1.3.js"></SCRIPT> 
<SCRIPT type="text/javascript" src="js/alertbox.js"></SCRIPT> 
<LINK rel="stylesheet" type="text/css" media="all" href="js/style.css"> 

    <script type="text/javascript"> 
      $(document).ready(function() { 
      $("#textbox").keyup(function() { 
    $.getJSON('check.jsp', { 
     textboxname: this.value 
    },function(data){ 
     if(data.isTrue){ 
      $("#textbox").val(''); //clear the text box 
      csscody.alert("username already exists");// here alert is coming 
       } 
     else{ 
     } 
    }); 
}); 
}); 
    </script> 
</head> 
<body> 
     <input type="text" id="textbox" name="textboxname" style="position: absolute; width: 250px; left: 110px; top: 40px;" /> 
<br/><br/> 

// The following two combo boxes are getting vanished after alert why 
<select id="" name="" style="position: absolute; left: 600px; top: 40px; width: 250px;"> 
    <option value=""></option> 
     <option value="somedata">somedata</option> 
      </select> 
<br/><br/> 
<select id="" > 
    <option value="_"></option> 
    <option value="somedata">somedata</option> 
     </select> 
</body> 
</html> 

check.jsp

JSONObject jsonObj= new JSONObject(); 
jsonObj.put("isTrue","true"); 
response.setContentType("application/json"); 
response.getWriter().write(jsonObj.toString()); 
+0

我已经给check.jsp还请大家为什么组合框越来越消失后“用户名已存在”警惕什么建议吗? – Phillipa 2012-02-19 08:15:28

+0

奇怪的伙计组合框消失了! – Tom 2012-02-19 08:34:30

+0

雅,但可能是什么原因?请建议一个可能的解决方案 – Phillipa 2012-02-19 08:35:19

回答

5

它都可以与您的代码。当我开始调试你的代码,我看到了一些alertbox.js有趣的事情:(线141和178)

if (!$.support.maxHeight) { //IE6 
       $('embed, object, select').css({ 'visibility' : 'hidden' }); 
    } 

此代码检测IE6(如果读了评论),但似乎它的越野车。

只是评论这些行,你的问题将得到解决。

不要忘了发布这个错误! 祝你好运。并开始使用调试器:)

+0

非常感谢你问题修复! – Phillipa 2012-02-19 15:05:28

+0

它总是更好地显示内容后关闭警报,而不是改变代码.http://stackoverflow.com/a/9349626/880434 – 2012-02-19 15:06:43

+0

@ user1217615没问题,只是问问 – 2012-02-19 15:10:02

1

下面的代码将解决您的问题,

csscody.alert("username already exists",{ onComplete: function(){ 
      $('embed, object, select').css({ 'visibility' : 'visible' }); 
     } 
}); 
+1

非常感谢你我的问题是最后修复 – Phillipa 2012-02-19 15:06:55

+0

任何建议请在哪里错了:http://stackoverflow.com/questions/9377544/returning-sum-from-server-side-by-json – Phillipa 2012-02-21 12:28:56