1

Here is my code

Including the files for the datepicker:

<html>
    <head>
      <link rel="stylesheet"  type="text/css" media="all" href="css/jsDatePick_ltr.min.css"/>
       <script type="text/javascript" src="js/jsDatePick.min.1.3.js"></script>
       <script type="text/javascript">

            window.onload = function(){
                new JsDatePick({
                    useMode:2,
                    target:"date",
                    dateFormat:"%d-%m-%Y"
                });
            };

       </script>
    </head>

Here i want to show the datepicker in two fields date and date1, but it is not showing in one field:

     <body>
         <table width="600" border="0" cellspacing="0" cellpadding="0">
             <tr>
                 <td height="25">&nbsp;</td>
                 <td width="45" class="form_txt">Date : </td>
                 <td width="105"><input name="date"  style="color:black;background:white" type="text" id="date" style="" /></td>
                 <td width="87"><img src="../images/cal.jpg" width="36" height="18" /></td>
                 <td width="45" class="form_txt">Date1 : </td>
                 <td width="105"><input name="date"  style="color:black;background:white" type="text" id="date1" style="" /></td>
                 <td width="87"><img src="../images/cal.jpg" width="36" height="18" /></td>
             </tr>
         </table>
     </body>
 </html>
4

1 回答 1

1

您不能id在页面上多次具有相同的属性值...您需要创建两个jsDatePick...像这样:

 window.onload = function(){
    new JsDatePick({
      useMode:2,
      target:"date",
      dateFormat:"%d-%m-%Y"
    });
    new JsDatePick({
      useMode:2,
      target:"date2",
      dateFormat:"%d-%m-%Y"
    });
 };

然后你的 HTML 应该是

<td width="105"><input name="date"  style="color:black;background:white" type="text" id="date" style="" /></td>
<td width="105"><input name="date2"  style="color:black;background:white" type="text" id="date2" style="" /></td>

注意第二个input到现在使用date2的变化idname

于 2013-06-11T11:41:32.980 回答