newline.insertCell().innerHTML='
<input size=10 type="text" name="tt[]">
<input size=10 type="text" name="aa[]" id="begin_date_b">
<input type="reset" value="..." onclick="return showCalendar('begin_date_b', 'y-m-d');">--------这行是在每增加的一行中加日历控件,现在报错,不知哪位高手帮忙解决一下???
<input size=10 type="text" name="bb[]">
<input type="button" value="删除" onclick="del()"> </tr>'
改这样呢
onclick="return showCalendar(\'begin_date_b\', \'y-m-d\');">
<input size=10 type="text" name="tt[]">
<input size=10 type="text" name="aa[]" id="begin_date_b">
<input type="reset" value="..." onclick="return showCalendar('begin_date_b', 'y-m-d');">--------这行是在每增加的一行中加日历控件,现在报错,不知哪位高手帮忙解决一下???
<input size=10 type="text" name="bb[]">
<input type="button" value="删除" onclick="del()"> </tr>'
改这样呢
onclick="return showCalendar(\'begin_date_b\', \'y-m-d\');">
<form> <input size=10 type="text" name="aa[]" id="begin_date_b" >
<input type="reset" value="..."
onclick="return showCalendar('begin_date_b', 'y-m-d');">
</form>
但是FORM只是一行,我需要在每个动态文本框中都增加这个日历控件,所有就要在事件中加入,现在我和FORM一样的加入了,肯定是不对,所以出问题。
'
<input size=10 type="text" name="tt[]">
<input size=10 type="text" name="aa[]" id="begin_date_b"> <input type="reset" value="..."
onclick="return showCalendar('begin_date_b', 'y-m-d');">
<input size=10 type="text" name="bb[]">
<input type="button" value="删除" onclick="del()"> </tr>
'
你这样的赋值 整个单引号中的字符串 已经被 return showCalendar('begin_date_b', 'y-m-d');" 中的单引号截取了, 并不完整,你试着alert看看然后将每次赋值的 name 改写下, 用以区别
2008-08-08以下是我找的,不太好的
function checkaa()
{
var reg=/^\d{4}年(?:1[0-2]|[1-9])月$/;
var txt=document.getElementById("txt");
if(!reg.test(txt.value))
{
alert("请输入正确日期!如:2008-08-08");
txt.focus();
}
}
单引号内包含多个双引号,把双引号做为字符串处理,反之亦然!
<html>
<head>
<title>动态增加文本框 </title>
<script type="text/javascript" src="js/calendar.js"> </script>
<script type="text/javascript" src="js/calendar-zh.js"> </script> <script type="text/javascript" src="js/calendar-setup.js"> </script>
<script type="text/javascript">
<!-- var textNumber = 1;
function addTitle(rows){
return "提醒" + (rows+1) + ":";
}
function addaa(rows){
//return rows;
return " <input type=\"+text\" name=\"aa[]" + rows + "\" id=\"begin_date_b" + rows + "\" />" + " <input type=\"reset\" value=\"...\" onclick=\"return showCalendar('begin_date_b" + rows + "', 'y-m-d');\">";
}
function addbb(rows){
//return rows
return " <input type=\"+text\" name=\"bb[]" + rows + "\" id=\"bb" + rows + "\" />";
}
function addtt(rows){
//return rows;
return " <input type=\"+text\" name=\"tt[]" + rows + "\" id=\"tt" + rows + "\" />";
}
function addTextBox(worksId){
var works = document.getElementById(worksId);
var newRow = works.insertRow(-1);
var newCell = newRow.insertCell(0);
newCell.innerHTML = addTitle(textNumber);
newCell = newRow.insertCell(1);
newCell.innerHTML = addtt(textNumber);
newCell = newRow.insertCell(2);
newCell.innerHTML = addaa(textNumber);
newCell = newRow.insertCell(3);
newCell.innerHTML = addbb(textNumber);
textNumber++;
}
function removeTextBox(worksId){
var works = document.getElementById(worksId);
if(textNumber>1){
works.deleteRow(textNumber-2);
textNumber--;
}
}
//-->
</script>
<style type="text/css">
<!--
label {
display:block;
margin:.25em 0em;
}
-->
</style>
</head>
<body> <form method="POST" action="bb6cc.php">
<table border="0" id="works" cellpadding="0" cellspacing="0">
<label id="template">提醒1: <input type="text" name="tt[]" id="tt" />
<input type="text" name="aa[]" id="begin_date_b"> <input type="reset" value="..." onclick="return showCalendar('begin_date_b', 'y-m-d');">
<input type="text" name="bb[]" id="bb" /> </label>
<table id="works">
</table>
<p>
<input type="button" value="增加一行" onclick="addTextBox('works')" />
<input type="button" value="删除一行" onclick="removeTextBox('works')" />
<p> <input type="Submit" value="提交保存" /> </p>
</form>
</body>
</html>