dsmgcse8876 2016-02-07 04:53
浏览 41
已采纳

在HTML表单的文本输入字段上选择后,无法使DatePicker正常工作

I have a HTML edit form that shows fields from database and allow users to edit the database fields. For one of the fields which is known as "detentiondate", I plan to put a date picker. So that when clicked to edit the date, a datepicker will be shown and I can retrieve the new date and update to the database. My date format is in mm/dd/yyyy (e.g. 01/28/2016).

Now I have trouble getting the datepicker to show up once I click on the textfield. Here is my code and please let me know where have I went wrong, thank you!

<script>
     $(document).ready(function() {     
     $('#selectDate').datepicker({
     dateFormat: "mm/dd/yy",
     onSelect: function(dateEdit, inst) {

       if (dateEdit.trim().length != 0) {      
                var dateSelected = new Object();
                dateSelected.latedate = dateEdit;                        
            } 
    }
});

});
</script>

<input id="selectDate" type="text" name="detentiondate<?php echo $StudLateDetails['lateid'] ?>" size="15" value="<?php echo $StudLateDetails['detentiondate'] ?>"/>

//This is gotten from the page source which shows the database field values
<input id="selectDate" type="text" name="detentiondate21" size="15" value="01/28/2016"/></tr>
  • 写回答

1条回答 默认 最新

  • dongrong7267 2016-02-07 05:18
    关注

    Ok You Add class name in textbox like this

    you change Script include line this order

     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
    
    
    <script src="//code.jquery.com/jquery-1.10.2.js"></script>
    <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
    <link rel="stylesheet" href="/resources/demos/style.css">
    
    <script>
     $(document).ready(function() {     
     $('.selectDate').datepicker({
     dateFormat: "mm/dd/yy",
     onSelect: function(dateEdit, inst) {
    
       if (dateEdit.trim().length != 0) {      
                var dateSelected = new Object();
                dateSelected.latedate = dateEdit;                        
            } 
    }
    });
    
    });</script>
    
    <input id="selectDate<?php echo $StudLateDetails['lateid'] ?>" class="selectDate" type="text" name="detentiondate<?php echo $StudLateDetails['lateid'] ?>" size="15" value="<?php echo $StudLateDetails['detentiondate'] ?>"/>
    

    This code Working fine

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 寻找一位有逆向游戏盾sdk 应用程序经验的技术
  • ¥15 请问有用MZmine处理 “Waters SYNAPT G2-Si QTOF质谱仪在MSE模式下采集的非靶向数据” 的分析教程吗
  • ¥50 opencv4nodejs 如何安装
  • ¥15 adb push异常 adb: error: 1409-byte write failed: Invalid argument
  • ¥15 nginx反向代理获取ip,java获取真实ip
  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥15 复杂网络,变滞后传递熵,FDA