Jump to content

Javascript içinde asp


Recommended Posts

Merhaba arkadaşlar,

Javascriptte for döngüsüyle 3 duyuru gösterecem şekilde asp'den duyuruları alacak bir kodlama yaptım.

3 tane aynı duyuruyu listeliyor.

for (var i=0;i < 3;i++) {

<% do while not rsDuyuru.eof or rsDuyuru.bof %>

messages="<a href=\"duyusu.asp?id=<%=rsDuyuru("id")%>\" class=\"yesil\"><b> <%=rsDuyuru("haberbaslik") %></b></a><br> <%=rsDuyuru("haberkisa") %><br>" ;

<%rsDuyuru.movenext

Loop%>

}

Link to comment
Share on other sites

sen messages değişkenini 3 defa döndürüyorsun ama id değişkenini 3 defa döndürmüyorsun. senin burda rs değişkeni içerisini döndürmen gerekiyor.

<%

for t=1 to 3

if rs.eof then exit for

%>

<a href=\"duyusu.asp?id=<%=rsDuyuru("id")%>\" class=\"yesil\"><b> <%=rsDuyuru("haberbaslik") %></b></a><br> <%=rsDuyuru("haberkisa") %><br>" ;

<%

rs.movenext

next

%>

dersen ilk 3ü alabilirsin. Senin kodunda eğer db yi çevirse bile. 1 2 3 1 2 3 1 2 3 olarak çevirecektir. 3 defa db de ne varsa sıralayacak

Link to comment
Share on other sites

sen messages değişkenini 3 defa döndürüyorsun ama id değişkenini 3 defa döndürmüyorsun. senin burda rs değişkeni içerisini döndürmen gerekiyor.

<%

for t=1 to 3

if rs.eof then exit for

%>

<a href=\"duyusu.asp?id=<%=rsDuyuru("id")%>\" class=\"yesil\"><b> <%=rsDuyuru("haberbaslik") %></b></a><br> <%=rsDuyuru("haberkisa") %><br>" ;

<%

rs.movenext

next

%>

dersen ilk 3ü alabilirsin. Senin kodunda eğer db yi çevirse bile. 1 2 3 1 2 3 1 2 3 olarak çevirecektir. 3 defa db de ne varsa sıralayacak

ilgin için teşekkürler.Fakat daha sorun devam ediyor..

Javascript kodları arasında asp kodu kullanıyorum.Duyuru bölümü için güzel bir javascript kodu.

Fakat adamlar array'ı manuel olarak yapmışlar;

messages[0]="Merhaba...";
messages[1]="Bu bir denemedir";
messages[2]="Bir üçüncü mesajdır..";[/CODE]

Ben ise bu messages[0]... olayını for döngüsüyle halettim.

[CODE]
for (var i=0;i < 3;i++) {

messages[i]="<a href=\"duyuru.asp?id=<%=rsDuyuru("id")%>\" class=\"mavi\"><b> <%=rsDuyuru("duyuru") %></b></a><br> <%=rsDuyuru("tarih") %><br>";

} [/CODE]

Şimdi benim merak ettiğim veritabanından 3-5-10 kaydı nasıl alacak ???

Link to comment
Share on other sites

  • 2 hafta sonra ...

<table width="150" height="100" cellpadding="0" cellspacing="0">
<tbody>
<tr></tr>
<tr>
<td width="102" class="t2_orta"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>

<td height="100" class="duyuru_yazi"><script language="JavaScript" type="text/javascript">
<!--
var scrollerdelay='4000' //delay between msg scrolls. 3000=3 seconds.
var scrollerwidth='147px'
var scrollerheight='100px'
var scrollerbgcolor=''
//set below to '' if you don't wish to use a background image
var scrollerbackground=''
var statusStyle = "font-family: Arial, Helvetica, sans-serif; color: #4C4C4C; font-size: 9px; font-weight:bold;";

//configure the below variable to change the contents of the scroller,




var messages=new Array();




for (var i=0;i < 5;i++) {





messages[0]="<a href=\"duyuru.asp\" target=\"_self\" class=\"mavi\"><b> Bunu asp içinde döngülü yapabilecek</b></a><br> Verileri veritabanından alacak şekilde yapılması gerekiyor<br>";
messages[1]="<a href=\"duyuru.asp\" target=\"_self\" class=\"mavi\"><b> Bak bu ikinci mesaj</b></a><br> Verileri veritabanından alacak şekilde<br>";

}



var running = 0;
var stopped = 0;
var stopCompleted = 0;
var scrollForward = 1;
var topLayer;
var bottomLayer;

var ie=document.all
var dom=document.getElementById

if (messages.length>2)
i=2
else
i=0

function move1(whichlayer){
tlayer=eval(whichlayer)
if (tlayer.top>0&&tlayer.top<=5){
tlayer.top=0
setTimeout("move1(tlayer)",scrollerdelay)
setTimeout("move2(document.main.document.second)",scrollerdelay)
return;
}
if (tlayer.top>=tlayer.document.height*-1){
tlayer.top-=5
setTimeout("move1(tlayer)",50)
}
else{
tlayer.top=parseInt(scrollerheight)
tlayer.document.write(messages[i])
tlayer.document.close()
if (i==messages.length-1)
i=0
else
i++
}
}

function move2(whichlayer){
tlayer2=eval(whichlayer)
if (tlayer2.top>0&&tlayer2.top<=5){
tlayer2.top=0
setTimeout("move2(tlayer2)",scrollerdelay)
setTimeout("move1(document.main.document.first)",scrollerdelay)
return
}
if (tlayer2.top>=tlayer2.document.height*-1){
tlayer2.top-=5
setTimeout("move2(tlayer2)",50)
}
else{
tlayer2.top=parseInt(scrollerheight)
tlayer2.document.write(messages[i])
tlayer2.document.close()
if (i==messages.length-1)
i=0
else
i++
}
}

function move3(whichdiv){
tdiv=eval(whichdiv)
if (parseInt(tdiv.style.top)>0&&parseInt(tdiv.style.top)<=5){
tdiv.style.top=0+"px"
if (stopped == 1) {switchButton(1); return;}
setTimeout("move3(tdiv)",scrollerdelay)
setTimeout("move4(second2_obj)",scrollerdelay)
return
}
if (parseInt(tdiv.style.top)>=tdiv.offsetHeight*-1){
if (stopped == 1 && parseInt(tdiv.style.top) == 0) {switchButton(1); return;}
if (stopped == 1 && parseInt(tdiv.style.top) == parseInt(scrollerheight)) {switchButton(1); return;}
tdiv.style.top=parseInt(tdiv.style.top)-5+"px"
setTimeout("move3(tdiv)",50)
}
else{
tdiv.style.top=parseInt(scrollerheight)
tdiv.innerHTML=messages[i]
itemStatus();
if (i==messages.length-1)
i=0
else
i++
}
}

function move4(whichdiv){
tdiv2=eval(whichdiv)
if (parseInt(tdiv2.style.top)>0&&parseInt(tdiv2.style.top)<=5){
tdiv2.style.top=0+"px"
if (stopped == 1) {switchButton(1); return;}
setTimeout("move4(tdiv2)",scrollerdelay)
setTimeout("move3(first2_obj)",scrollerdelay)
return
}
if (parseInt(tdiv2.style.top)>=tdiv2.offsetHeight*-1){
if (stopped == 1 && parseInt(tdiv2.style.top) == 0) {switchButton(1); return;}
if (stopped == 1 && parseInt(tdiv2.style.top) == parseInt(scrollerheight)) {switchButton(1); return;}
tdiv2.style.top=parseInt(tdiv2.style.top)-5+"px"
setTimeout("move4(second2_obj)",50)
}
else{
tdiv2.style.top=parseInt(scrollerheight)
tdiv2.innerHTML=messages[i]
itemStatus();
if (i==messages.length-1)
i=0
else
i++
}
}

function startscroll(){
// make sure function doesn't fun twice
if (running != 0)
return

running++

if (ie||dom){
first2_obj=ie? first2 : document.getElementById("first2")
second2_obj=ie? second2 : document.getElementById("second2")
move3(first2_obj)
second2_obj.style.top=scrollerheight
second2_obj.style.visibility='visible'
switchButton(0);

document.getElementById("itemStatus").innerHTML = '<span id="itemStatus" class="yazi" style="' + statusStyle + '">1 / ' + messages.length + '</span>';
}
else if (document.layers){

document.main.visibility='show'
move1(document.main.document.first)
document.main.document.second.top=parseInt(scrollerheight)+5
document.main.document.second.visibility='show'
}
}

function itemStatus() {

document.getElementById("itemStatus").innerHTML = '<span id="itemStatus" style="' + statusStyle + '">' + (i==0?messages.length:i) + ' / ' + messages.length + '</span>';
}

function stopScroll() {
stopped = 1;
switchButton(2);
}

function restartScroll() {
if (stopped == 0 ) {return;}
stopped = 0;
if (scrollForward == 0) {
if (i==messages.length-1) {
i=1;
} else if (i==messages.length-2) {
i=0;
} else {
i=i+2
}
}

move3(first2_obj);
move4(second2_obj);

switchButton(0);
scrollForward = 1;
stopCompleted = 0;
}


function switchButton(what) {
if (what==0) {
document.getElementById("startstop").innerHTML = '<a href="java script:stopScroll();"><img src="images/hold.gif" name="hold" border="0" align="middle" width="16" height="16" alt="Hareketi Dondur" onMouseOver="scrollIconSwap(\'hold\',this,0);" onMouseOut="scrollIconSwap(\'hold\',this,1);"></a>';
document.getElementById("nextbutton").innerHTML = '<a href="java script:nextScroll();"><img src="images/forward.gif" name="forward" border="0" align="absmiddle" width="14" height="20" alt="sonraki Duyuru" onMouseOver="scrollIconSwap(\'forward\',this,0);" onMouseOut="scrollIconSwap(\'forward\',this,1);"></a>';
document.getElementById("backbutton").innerHTML = '<a href="java script:backScroll();"><img src="./images/back.gif" name="back" border="0" align="absmiddle" width="14" height="20" alt="Önceki Duyuru" onMouseOver="scrollIconSwap(\'back\',this,0);" onMouseOut="scrollIconSwap(\'back\',this,1);"></a>';
} else if (what==1) {
first2_top=parseInt(document.getElementById("first2").style.top)
second2_top=parseInt(document.getElementById("second2").style.top)
if ((first2_top != 0 && first2_top != parseInt(scrollerheight)) || (second2_top != 0 && second2_top != parseInt(scrollerheight))) {
setTimeout("switchButton(1)",50)
return;
}
document.getElementById("startstop").innerHTML = '<a href="java script:restartScroll();"><img src="images/scroll.gif" name="scroll" border="0" align="middle" width="16" height="16" alt="Devam Et" onMouseOver="scrollIconSwap(\'scroll\',this,0);" onMouseOut="scrollIconSwap(\'scroll\',this,1);"></a>';
document.getElementById("nextbutton").innerHTML = '<a href="java script:nextScroll();"><img src="images/forward.gif" name="forward" border="0" align="absmiddle" width="14" height="20" alt="Sonraki Duyuru" onMouseOver="scrollIconSwap(\'forward\',this,0);" onMouseOut="scrollIconSwap(\'forward\',this,1);"></a>';
document.getElementById("backbutton").innerHTML = '<a href="java script:backScroll();"><img src="images/back.gif" name="back" border="0" align="absmiddle" width="14" height="20" alt="Önceki Duyuru" onMouseOver="scrollIconSwap(\'back\',this,0);" onMouseOut="scrollIconSwap(\'back\',this,1);"></a>';
stopCompleted = 1;
} else if (what==2) {
document.getElementById("startstop").innerHTML = '<img src="./images/wait.gif" border="0" align="middle" width="17" height="17" alt="Lütfen Bekleyin...">';
document.getElementById("nextbutton").innerHTML = '<img src="images/forward.gif" name="forward" border="0" align="absmiddle" width="14" height="20" alt="Sonraki Duyuru">';
document.getElementById("backbutton").innerHTML = '<img src="images/back.gif" name="back" border="0" align="absmiddle" width="14" height="20" alt="Önceki Duyuru">';
}
}

function nextScroll() {
if (stopped == 0) { stopScroll(); }
if (stopCompleted == 0) {
setTimeout("nextScroll()",50)
return;
}
if (parseInt(document.getElementById("first2").style.top)==0) {
topLayer = document.getElementById("first2");
bottomLayer = document.getElementById("second2");
} else {
bottomLayer = document.getElementById("first2");
topLayer = document.getElementById("second2");
}
if (scrollForward == 0) {
if (i==messages.length-1) {
i=1;
} else if (i==messages.length-2) {
i=0;
} else {
i=i+2
}
}
eval(topLayer).innerHTML = (i==0?messages[messages.length-1]:messages[i-1]);
eval(bottomLayer).innerHTML = messages[i];
itemStatus();
scrollForward = 1;
if (i==messages.length-1) {
i=0;
} else {
i++;
}
}

function backScroll() {
if (stopped == 0) { stopScroll(); }
if (stopCompleted == 0) {
setTimeout("backScroll()",50)
return;
}
if (parseInt(document.getElementById("first2").style.top)==0) {
topLayer = document.getElementById("first2");
bottomLayer = document.getElementById("second2");
} else {
bottomLayer = document.getElementById("first2");
topLayer = document.getElementById("second2");
}
if (scrollForward == 1) {
if (i==0) {
i=messages.length-2;
} else if (i==1) {
i=messages.length-1;
} else {
i=i-2
}
}
//alert(i);
if(i==-1)
{
i =0;
}
eval(topLayer).innerHTML = (i==0?messages[messages.length-1]:messages[i-1]);
eval(bottomLayer).innerHTML = messages[i];
itemStatus();
scrollForward = 0;
if (i==0) {
i=messages.length-1;
} else {
i--;
}
}

function scrollIconSwap(iconImg, what, which) {
var imgPath = "./images/";
if (which == 0) {
what.src = imgPath + iconImg + "_over.gif";
} else {
what.src = imgPath + iconImg + ".gif";
}
}

window.onload=startscroll

//-->
</script>
<ilayer id="main" background="&{scrollerbackground};"
bgcolor="&{scrollerbgcolor};" visibility="hide"
height="&{scrollerheight};"
width="&{scrollerwidth};" top="-1">
<layer id="first"
width="&{scrollerwidth};" top="1" left="0">
<script language="JavaScript" type="text/javascript">
if (document.layers)
document.write(messages[0])
</script>
</layer>
<layer id="second" visibility="hide"
width="&{scrollerwidth};" top="0" left="0">
<script language="JavaScript" type="text/javascript">
if (document.layers)
document.write(messages[dyndetermine=(messages.length==1)? 0 : 1])
</script>
</layer>
</ilayer>
<script language="JavaScript" type="text/javascript">
<!--
if (ie||dom){
document.writeln('<div id="main2" style="position:relative;width:'+scrollerwidth+';height:'+scrollerheight+';overflow:hidden;background-color:'+scrollerbgcolor+';background-image:url('+scrollerbackground+')">')
document.writeln('<div style="position:absolute;width:'+scrollerwidth+';height:'+scrollerheight+';clip:rect(0 '+scrollerwidth+' '+scrollerheight+' 0);left:0px;top:0px">')
document.writeln('<div id="first2" style="position:absolute;width:'+scrollerwidth+';left:0px;top:1px;">')
document.write(messages[0])
document.writeln('</div>')
document.writeln('<div id="second2" style="position:absolute;width:'+scrollerwidth+';left:0px;top:0px;visibility:hidden">')
document.write(messages[dyndetermine=(messages.length==1)? 0 : 1])
document.writeln('</div>')
document.writeln('</div>')
document.writeln('</div>')
}
//-->
</script>
<table cellspacing="0" cellpadding="0" width="100%"
border="0">
<tbody>
<tr>
<td><span id="startstop"></span></td>
<td align="right"><script language="JavaScript" type="text/javascript">
<!--
document.writeln('<span id="backbutton"></span><span id="itemStatus" style="' + statusStyle + '"></span><span id="nextbutton"></span>');
//-->
</script>
</td>
</tr>
</tbody>
</table></td>
</tr>
</tbody>
</table></td>
<td class="t2_sagalt" width="5"> </td>
</tr>
</tbody>
</table>[/CODE]

ayrıntılı kodlar burada bilgiyi veritabanından alacak şekilde nasıl yapabilirim? :D

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...