Voila, mon soucis, je dois faire un petit script qui permet sur la page d'accueil du site, de faire defiler les infos du jour.
Voici le code que j'ai fait et qui marche:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
 
<?
require_once($GLOBALS[DOCUMENT_ROOT]."/inc/****.php");         //  les classes
require_once($GLOBALS[DOCUMENT_ROOT]."/inc/******.php");   // la session
?>
<table align="center" border="0" cellspacing="0" cellpadding="0" >
	<tr>
    	<td width="17"><a href="#"><img border="0" src="/new_charte/images/index/fildinfos_03.gif" ></a>
		</td>
        <td style="background-image:url(/new_charte/images/index/fildinfos_04.gif);background-repeat: repeat-x;font-family:Arial, Helvetica, sans-serif; font-size:12px;" valign="middle">
		</td>
		<td  width="17"><a href="#"><img src="/new_charte/images/index/fildinfos_06.gif" border="0"></a>
		</td>
	</tr>
</table>
 
<script language="JavaScript1.2">
// Les variables de style à changer :
var scrollerwidth='150px' // Largeur
var scrollerheight='180px' // Hauteur
var scrollerbgcolor='#f6f5fd' // Couleur de fond
var scrollerbackground='' // L'image de fond
var scrollertime='4000' // temps d'attente entre chaque info
 
<?
//constantes
$art_a_afficher="10";
$nbre_carac="100";
 
mysql_select_db($database_CONN_MAB, $connexion);
$query_news = "SELECT NEWS_ARTICLE.*, NEWS_RUBRIQUE.RUBRIQUE FROM NEWS_ARTICLE, NEWS_RUBRIQUE WHERE NEWS_ARTICLE.ID_RUBRIQUE=NEWS_RUBRIQUE.ID_RUBRIQUE and ETAT='V' and (NEWS_ARTICLE.LANGUAGE='".$_SESSION['site_language']."' or NEWS_ARTICLE.LANGUAGE='INT') ORDER BY DATE DESC, HEURE DESC limit 0,". $art_a_afficher;
$news = mysql_query($query_news, $connexion) or die(mysql_error());
$totalRows_news = mysql_num_rows($news);
$i=0;
$messages=array();
while ($row_news = mysql_fetch_assoc($news))
{
	$ppp = "SELECT customers_login from osc_customers where customers_id=".$row_news['ID_PERSONNE'];
	$pp = mysql_fetch_assoc(mysql_query($ppp, $connexion));
	$string[$i]=$row_news['TEXTE'];
 
	$messages[$i]="<img src=# height=8 width=4> le <b>".substr($row_news['DATE'],8,2)."/".substr($row_news['DATE'],5,2)." </b><a href=/news/archives_". $row_news['SEMAINE'] .".htm#". $row_news['ID_NEWS'] .">". $row_news['TITRE'] ."</a><br /><div align=right> par ".$pp[customers_login]."</div><br />".substr(strip_tags(preg_replace('/\s\s+/', ' ',ereg_replace("[\r\n\t]", ' ', html_entity_decode($row_news['TEXTE'])))),0,$nbre_carac)." ...<br /><div align=right>".$row_news['NB_COMMENT']." réacs</div>";
 
	$i=$i+1;
} 
/*echo implode("\",\"", $messages);
exit;*/
echo "var messages = new Array(\"" . implode("\",\"", $messages) . "\");";
 
?>
 
// Ne plus rien changer dessous
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)",scrollertime)
		setTimeout("move2(document.main.document.second)",scrollertime)
		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)",scrollertime)
		setTimeout("move1(document.main.document.first)",scrollertime)
		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"
		setTimeout("move3(tdiv)",scrollertime)
		setTimeout("move4(second2_obj)",scrollertime)
		return
	}
	if (parseInt(tdiv.style.top)>=tdiv.offsetHeight*-1)
	{
		tdiv.style.top=parseInt(tdiv.style.top)-5+"px"
		setTimeout("move3(tdiv)",50)
	} 
	else
	{
		tdiv.style.top=parseInt(scrollerheight)
		tdiv.innerHTML=messages[i]
		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"
		setTimeout("move4(tdiv2)",scrollertime)
		setTimeout("move3(first2_obj)",scrollertime)
		return
	}
	if (parseInt(tdiv2.style.top)>=tdiv2.offsetHeight*-1)
	{
		tdiv2.style.top=parseInt(tdiv2.style.top)-5+"px"
		setTimeout("move4(second2_obj)",50)
	}
	else
	{
		tdiv2.style.top=parseInt(scrollerheight)
		tdiv2.innerHTML=messages[i]
		if (i==messages.length-1)
			i=0
		else
			i++
	}
}
 
function startscroll()
{
	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'
	}
	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'
	}
}
 
window.onload=startscroll
</script>
<table border="0" align="center" cellspacing="0">
  <tr><td style="background-repeat: repeat-x;font-family:Arial, Helvetica, sans-serif; font-size:12px;" valign="middle">
<ilayer id="main" width=&{scrollerwidth}; height=&{scrollerheight}; bgColor=&{scrollerbgcolor}; background=&{scrollerbackground}; visibility=hide>
<layer id="first" left=0 top=1 width=&{scrollerwidth};>
<script language="JavaScript1.2">
if (document.layers)
document.write(messages[0])
</script>
</layer>
<layer id="second" left=0 top=0 width=&{scrollerwidth}; visibility=hide>
<script language="JavaScript1.2">
if (document.layers)
document.write(messages[dyndetermine=(messages.length==1)? 0 : 1])
</script>
</layer>
</ilayer>
<script language="JavaScript1.2">
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>
</td></tr>
 
</table>
j'ai bien mes infos qui defilent les unes a la suite des autres avec un temps d'attente entre chaque info de 4 secondes.

Ce que je veux faire, c'est un bouton précédent et un bouton suivant pour soit revenir à l'info précédente ou passer à l'info suivante. Et qu'ensuite le défilement reprend.

Si quelqu'un à déjà fait ceci, ça serait sympa de m'aiguiller car je n'ai aucune piste, d'avance merci