简体   繁体   English

jQuery UI Datepicker仅响应第一个文本框

[英]jQuery UI Datepicker only respond to the first textbox

I'm trying to create a table with multiple rows and each row has a text box for user to input the date using the jQuery UI Datepicker. 我正在尝试创建一个具有多行的表,每行都有一个文本框,供用户使用jQuery UI Datepicker输入日期。 The problem is that the Datepicker is only updating the text box in the first row. 问题在于Datepicker仅更新第一行中的文本框。 Here is the datepicker function in the <head> : 这是<head>的datepicker函数:

<script>
$(function() {
    $('.dateinput').datepicker({ dateFormat: 'dd/mm/yy' }).val();
});
</script>

This is the text box: 这是文本框:

<?php
while($fetch = mysql_fetch_array($query))
{
    echo "<td> <input type='text' id='dateinput' name='dateinput[]' value='" .date('d/m/Y'). "' class='dateinput' /> </td>";
}
?>

Any help would be very much appreciated. 任何帮助将不胜感激。 :) :)

You have problem due to Same Id which conflict You can use same class name 由于存在相同的ID而导致冲突,您可以使用相同的类名

class='dateinput'

It work's 有用

You are getting this problem as all rows have 由于所有行都出现此问题

id='dateinput'

You need to give them different id. 您需要给他们提供不同的ID。 Keep a counter variable and append it to id. 保留一个计数器变量并将其附加到id。 Increase it in loop after appending. 追加后循环增加。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM