【发布时间】:2011-03-30 23:05:38
【问题描述】:
我有一个日期数组。 下面的代码循环遍历日期以打印出带有文本字段的日期。 我要做的是创建一个具有唯一 ID 的文本字段数组。 然后将每个日期及其数组文本字段(值)传递到 php 脚本中。
有什么想法吗?
for (var i in dates) {
var d = dates[i];
if (d) { // sometimes the date is not actually selected, that's why we need to check.
var length = 12;
var str = i+d;
var myUniqueTime = str.substring(0,length);
myUniqueTime = myUniqueTime.replace(/^\s+|\s+$/g, '');
times= ["<input type=\"text\" id=\""+i+"\" size=\"8\" name=\""+i+"\" onChange=\"changeTimeTo24Hrs()\" value=\""+i+"\" />", "<input type=\"text\" id=\"times\" size=\"8\" name=\"times\" value=\""+i+"\" />"];
// OK, selected. Fill an input field. Or something. Just for example,
// we will display all selected dates in the element having the id "output".
el.innerHTML += "I = " + i + "<br />" + times + "<br />" + d.print("%A, %Y %B %d") + " <font size='-1'>" + myUniqueTime + "</font><br /><BR />";
}
}
【问题讨论】:
标签: php javascript jquery arrays loops