大家帮忙看下啊!!
<html>
<head>
<script language= "javascript ">
var imgsStr= " ";
var tmpArray=new Array();
var str= "2007091900aa;2007091901bb;2007091909cc;2007091925dd ";
var dateStr= "20070919012007091923 ";
function getImgsByDate(){
imgsStr=trim(str);
tmpArray=imgsStr.split( "; ");
imgsArray=new Array();
if(dateStr.length==8){
for(var i=0;i <tmpArray.length;i++){
if(tempArray[i].indexOf(dateStr)!=-1){
imgsArray[imgsArray.length]=tmpArray[i];
}
}
}
else{
var star=dateStr.substring(0, 10);
var end=dateStr.substring(10, 20);
for(var i=0;i <tmpArray.length;i++){
if (tempArray[i]> =star)
{if(tempArray[i] <=end)
imgsArray[imgsArray.length]=tmpArray[i];
alert(tmpArray[i]);
}
}
}
}
}
</script>
</head>
<body>
<input type= "button " value= "click " onclick= "getImgsByDate() ">
</body>
</html>
一直提示缺少对象和语法错误,实在找不到是那里的问题,请大家帮忙看下。多谢~~
------解决方案-------------------- <html>
<head>
<script language= "javascript ">
var imgsStr= " ";
var tmpArray=new Array();
var str= "2007091900aa;2007091901bb;2007091909cc;2007091925dd ";
var dateStr= "20070919012007091923 ";
function getImgsByDate(){
imgsStr=trim(str);
tmpArray=imgsStr.split( "; ");
imgsArray=new Array();
if(dateStr.length==8){
for(var i=0;i <tmpArray.length;i++){
if(tempArray[i].indexOf(dateStr)!=-1){
imgsArray[imgsArray.length]=tmpArray[i];
}
}
}else{
var star=dateStr.substring(0, 10);
var end=dateStr.substring(10, 20);
for(var i=0;i <tmpArray.length;i++){
if (tmpArray[i]> =star){
if(tmpArray[i] <=end)
imgsArray[imgsArray.length]=tmpArray[i];
alert(tmpArray[i]);
}
}
}
}
function trim(str){
return str.replace(/(^\s*)|(\s*$)/g, " ");
}
</script>
</head>
<body>
<input type= "button " value= "click " onc