日期选择器无法使用javascript显示

时间:2012-09-04 16:11:36

标签: javascript jquery datepicker

为什么日期选择器不显示..我希望日期选择器以2形式显示,因为它有日期开始和日期结束.......... 谢谢你的帮助......

<script type="text/javascript" src="jquery.1.4.2.js"></script>
<script type="text/javascript" src="jsDatePick.jquery.min.1.3.js"></script>
<script type="text/javascript">
window.onload = function(){
    new JsDatePick({
        useMode:2,
        target:"inputField",
        dateFormat:"%d-%M-%Y"
    });
};
</script>
<form action="index.php?page=form" method="post">
<table>
    <tr>
    <td>
        Date Start
    </td>
    <td>
        <input type="text" name="date1" id="inputField">
    </td>
    </tr>
    <tr>
    <td>
        Date Finish
    </td>
    <td>
        <input type="text" name="date2" id="inputField">
    </td>
    </tr>

  </table>

2 个答案:

答案 0 :(得分:0)

<script type="text/javascript" src="jquery.1.4.2.js"></script>
<script type="text/javascript" src="jsDatePick.jquery.min.1.3.js"></script>
<script type="text/javascript">
window.onload = function(){
    new JsDatePick({
        useMode:2,
        target:"inputField",
        dateFormat:"%d-%M-%Y"
    });

    new JsDatePick({
        useMode:2,
        target:"inputField2",
        dateFormat:"%d-%M-%Y"
    });
};
</script>
<form action="index.php?page=form" method="post">
<table>
    <tr>
    <td>
        Date Start
    </td>
    <td>
        <input type="text" name="date1" id="inputField">
    </td>
    </tr>
    <tr>
    <td>
        Date Finish
    </td>
    <td>
        <input type="text" name="date2" id="inputField2">
    </td>
    </tr>

  </table>

答案 1 :(得分:0)

ID应该是唯一的,您应该为输入字段分配不同的ID。还要将代码包装在$(document).ready( function()之内;

$(document).ready( function(){
  new JsDatePick({
    useMode:2,
    target:"inputField",
    dateFormat:"%d-%M-%Y"
  });
  new JsDatePick({
    useMode:2,
    target:"inputField2",
    dateFormat:"%d-%M-%Y"
  });
});

注意:我没有测试过这个。