jQuery UI Datepicker只响应第一个文本框 [英] jQuery UI Datepicker only respond to the first textbox

查看:98
本文介绍了jQuery UI Datepicker只响应第一个文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个多行的表,每行都有一个文本框,供用户使用jQuery UI Datepicker输入日期。问题是Datepicker只是更新第一行的文本框。以下是< head> 中的datepicker函数:

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. The problem is that the Datepicker is only updating the text box in the first row. Here is the datepicker function in the <head>:

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

这是文本框:

<?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 are getting this problem as all rows have

id='dateinput'

你需要给他们不同ID。
保留一个counter变量并将其附加到id。

You need to give them different id. Keep a counter variable and append it to id. Increase it in loop after appending.

希望这有帮助。

这篇关于jQuery UI Datepicker只响应第一个文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆