Грешка в js

hellfire

Registered
Здравейте тия дни заради AJAX и един пич научих малко js и стигнах до тук
но не знам каде ми е грешката
Код:
<script>
function counter(nz){
var dokumenta = document.send.link.value;
 var array = dokumenta.split("http://");
 var count = array.length-1;
  var lastcount = 0;
 for(var i = 0; i < count; i ++){
 var tipfail = array[i].split(".");
  if((tipfail != "rar") && (tipfail != "zip") && (tipfail != "mp3") && (tipfail != "iso") && (tipfail != "jpg") && (tipfail != "tr") && (tipfail != "mov") && (tipfail != "jpg") && (tipfail != "wmv") && (tipfail != "ace") && (tipfail != "ico") && (tipfail != "jpeg") && (tipfail != "avi") && (tipfail != "3gp") && (tipfail != "mp4") && (tipfail != "cue") && (tipfail != "srt") && (tipfail != "txt") && (tipfail != "bin") && (tipfail != "gif") && (tipfail != "sub") && (tipfail != "bmp") && (tipfail != "mpg") && (tipfail != "bat") && (tipfail != "img") && (tipfail != "wma") && (tipfail != "ac3") && (tipfail != "wav") && (tipfail != "tar") && (tipfail != "mpeg") && (tipfail != "png") && (tipfail != "com") && (tipfail != "exe") && (tipfail != "tiff") && (tipfail != "pdf") && (tipfail != "sql") && (tipfail != "html") && (tipfail != "JPG") && (tipfail != "doc") && (tipfail != "htm") && (tipfail != "xls"))
 { } else{
 lastcount += 1;
 }
 }
 alert(lastcount);
 document.send.counts.value=count;
 }
 </script>
моля ви помогнете ми :cry: явно при if(tipfail ...) моля ви хелп
 
пробвай така макар да не знам какво точно се опитваш да правиш
<script>
function counter(){
var dokumenta = document.send.link.value;
var dokumenta ='http://www.ms-dev.com/bookmarks/onedream.html';
var array = dokumenta.split("http://");
var count = array.length-1;
var lastcount = 0;
var url=array[1];
var drugi=0;
var tipfail =url.split(".");
for(var i = 0; i<tipfail.length; i++){
alert(tipfail);
if((tipfail == "rar") || (tipfail == "zip") || (tipfail == "mp3") || (tipfail == "iso") || (tipfail == "jpg") || (tipfail == "tr") || (tipfail == "mov") || (tipfail == "jpg") || (tipfail == "wmv") || (tipfail == "ace") || (tipfail == "ico") || (tipfail == "jpeg") || (tipfail == "avi") || (tipfail == "3gp") || (tipfail == "mp4") || (tipfail == "cue") || (tipfail == "srt") || (tipfail == "txt") || (tipfail == "bin") || (tipfail == "gif") || (tipfail == "sub") || (tipfail == "bmp") || (tipfail == "mpg") || (tipfail == "bat") || (tipfail == "img") || (tipfail == "wma") || (tipfail == "ac3") || (tipfail == "wav") || (tipfail == "tar") || (tipfail == "mpeg") || (tipfail == "png") || (tipfail == "com") || (tipfail == "exe") || (tipfail == "tiff") || (tipfail == "pdf") || (tipfail == "sql") || (tipfail == "html") || (tipfail == "JPG") || (tipfail == "doc") || (tipfail == "htm") || (tipfail == "xls"))
{lastcount+=1;}else{
drugi+=1;
}
}
alert(lastcount);
document.send.counts.value=count;
}
</script>
 
не става имам предвид че показва винаги че е валиден линка ето го цялото
<script>
function counter(nz){
var dokumenta = document.send.link.value;
var array = dokumenta.split("http://");
var count = array.length-1;
var lastcount = 0;
var url=array[1];
var drugi=0;
var tipfail =url.split(".");
for(var i = 0; i<tipfail.length; i++){
if((tipfail == "rar") || (tipfail == "zip") || (tipfail == "mp3") || (tipfail == "iso") || (tipfail == "jpg") || (tipfail == "tr") || (tipfail == "mov") || (tipfail == "jpg") || (tipfail == "wmv") || (tipfail == "ace") || (tipfail == "ico") || (tipfail == "jpeg") || (tipfail == "avi") || (tipfail == "3gp") || (tipfail == "mp4") || (tipfail == "cue") || (tipfail == "srt") || (tipfail == "txt") || (tipfail == "bin") || (tipfail == "gif") || (tipfail == "sub") || (tipfail == "bmp") || (tipfail == "mpg") || (tipfail == "bat") || (tipfail == "img") || (tipfail == "wma") || (tipfail == "ac3") || (tipfail == "wav") || (tipfail == "tar") || (tipfail == "mpeg") || (tipfail == "png") || (tipfail == "com") || (tipfail == "exe") || (tipfail == "tiff") || (tipfail == "pdf") || (tipfail == "sql") || (tipfail == "html") || (tipfail == "JPG") || (tipfail == "doc") || (tipfail == "htm") || (tipfail == "xls"))
{lastcount+=1;}else{
drugi+=1;
}
}
alert(lastcount);
document.send.counts.value=count;
}
</script>
<form method="POST" name="send" action="?page=addsearch&a=a">
<center><textarea class="forma" rows="10" name="link" cols="56"><? echo $fdsfsd2; ?></textarea><br/>
<input type="text" name="counts" size="3" value="0">
<input type="button" value="Цъкни ме" class="forma" OnClick="counter('links');">
<input id="button" type="submit" value="submit" name="B1">
</form>
искам да отброя колко линка има и са валидни тоест раширението им е
от горния иф не ми се пише че е доста ..
ЕДИТ://
това го промених малко ето така
амм пак не става
<script>
function counter(nz){
var dokumenta = document.send.link.value;
var array = dokumenta.split("http://");
var count = array.length-1;
var lastcount = 0;
var drugi=0;
var tipfail = "";
for(var i = 0; i<count; i++){
vars = array.split(".");
tipfail = vars[vars.length-1];
if((tipfail == "rar") || (tipfail == "zip") || (tipfail == "mp3") || (tipfail == "iso") || (tipfail == "jpg") || (tipfail == "tr") || (tipfail == "mov") || (tipfail == "jpg") || (tipfail == "wmv") || (tipfail == "ace") || (tipfail == "ico") || (tipfail == "jpeg") || (tipfail == "avi") || (tipfail == "3gp") || (tipfail == "mp4") || (tipfail == "cue") || (tipfail == "srt") || (tipfail == "txt") || (tipfail == "bin") || (tipfail == "gif") || (tipfail == "sub") || (tipfail == "bmp") || (tipfail == "mpg") || (tipfail == "bat") || (tipfail == "img") || (tipfail == "wma") || (tipfail == "ac3") || (tipfail == "wav") || (tipfail == "tar") || (tipfail == "mpeg") || (tipfail == "png") || (tipfail == "com") || (tipfail == "exe") || (tipfail == "tiff") || (tipfail == "pdf") || (tipfail == "sql") || (tipfail == "html") || (tipfail == "JPG") || (tipfail == "doc") || (tipfail == "htm") || (tipfail == "xls"))
{lastcount+=1; alert('x');}else{
drugi+=1;
}
}
document.send.counts.value=lastcount;
}
</script>
 

Back
Горе