date picker

yingwho
yingwho used Ask the Experts™
on
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<link type="text/css" href="http://jqueryui.com/latest/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.core.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.datepicker.js"></script>
 <script type="text/javascript">
     $(document).ready(function() {
         $('input').filter('.datepicker').datepicker({
             changeMonth: true,
             changeYear: true,
             showOn: 'both',
             buttonImage: 'x.gif',
             buttonImageOnly: true
         });
             .datepicker( 'hide' , [speed] )
     });  

 </script>  
</head>
<body>
<table cellpadding="2" cellspacing="0">
      <tr>
            <td>
                  town
            </td>
            <td>                  
                  <input type="text" name="town" size="15"  />
            </td>
      </tr>
      <tr>
            <td>
                  date
            </td>
            <td>
                  <input type="text" name="da" size="15" class="datepicker" />
            </td>
      </tr>
      <tr>
            <td>
                  name
            </td>
            <td>
                  <input type="text" name="name" size="15" />
            </td>
      </tr>
</table>    
</body>
</html>

i need to hide the datepicker popup when i am on other fields based on the focus.
pl suggest.

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hi,

The date picker will automatically hide when it looses focus anyway. What breaks it is you hide script just remove the line
 .datepicker( 'hide' , [speed] )



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<link type="text/css" href="http://jqueryui.com/latest/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.core.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.datepicker.js"></script>
 <script type="text/javascript">
 $(document).ready(function() {
     $('.datepicker').datepicker({
         changeMonth: true,
         changeYear: true,
         showOn: 'both',
         buttonImage: 'x.gif',
         buttonImageOnly: true
     });
 });  

 </script>   
</head>
<body>
<table cellpadding="2" cellspacing="0"> 
      <tr>
            <td>
                  town
            </td>
            <td>                  
                  <input type="text" name="town" size="15"  />
            </td>
      </tr>
      <tr>
            <td>
                  date
            </td>
            <td>
                  <input type="text" name="da" size="15" class="datepicker" />
            </td>
      </tr>
      <tr>
            <td>
                  name
            </td>
            <td>
                  <input type="text" name="name" size="15" />
            </td>
      </tr>
</table>    
</body>
</html>

Open in new window

if you want to be sure you can always do this
$(document).ready(function() {
     $('.datepicker').datepicker({
         changeMonth: true,
         changeYear: true,
         showOn: 'both',
         buttonImage: 'x.gif',
         buttonImageOnly: true
     });
     $("input").not(".datepicker").focus(function(){
	 $(".datepicker").datepicker("hide",300);
     });
 });

Open in new window

Commented:
hi guys

both the solutions failed. if u tab fast u will know.

 .datepicker( 'hide' , [speed] ) -
the hint i gave was for the syntax, its not the actual syntax

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial