我有一组日期。 下面的代码在日期上循环显示带有文本字段的日期。 我想要做的是创建一个具有唯一ID的文本字段数组。 然后将每个日期与其数组文本字段(值)传递到一个PHP脚本。使用Javascript动态地为输入字段数组创建唯一ID
任何想法?
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 />";
}
}
好的,如果我想用javascript添加一个新的文本字段;有任何想法吗? – Buki 2011-03-30 23:40:47
哦,我该如何使它从JAVASCRIPT发布? – Buki 2011-03-30 23:41:31
http://www.javascript-coder.com/javascript-form/javascript-form-submit.phtml – 2011-03-30 23:50:20