Customizing SMF > SMF Coding Discussion
iwant to add java script to SSI.php
muayzing:
how can i add this java script to the SSI.php
with whosonline_function
--- Code: ---<script language="JavaScript1.2">
var variableslide=new Array()
variableslide[0]=['user1]
variableslide[1]=['user2']
variableslide[2]=['user3']
variableslide[3]=[user4']
variableslide[4]=[user5']
variableslide[5]=[' ... ']
//configure the below 3 variables to set the dimension/background color of the slideshow
var slidewidth=''
var slideheight=''
var slidebgcolor=''
//configure the below variable to determine the delay between image rotations (in miliseconds)
var slidedelay=1500
////Do not edit pass this line////////////////
var ie=document.all
var dom=document.getElementById
var currentslide=0
function rotatelink(){
contentcontainer=''
if (variableslide[currentslide][0]!="")
contentcontainer+='???????? [<a href="http://'
contentcontainer+=variableslide[currentslide][0]
contentcontainer+='.storythai.com" target=_blank>'
contentcontainer+=variableslide[currentslide][0]
contentcontainer+='</a>]'
if (document.layers){
crossrotateobj.document.write(contentcontainer)
crossrotateobj.document.close()
}
else if (ie||dom)
crossrotateobj.innerHTML=contentcontainer
if (currentslide==variableslide.length-1) currentslide=0
else currentslide++
setTimeout("rotatelink()",slidedelay)
}
if (ie||dom)
document.write('<div id="slidedom" style="width:'+slidewidth+';height:'+slideheight+'; background-color:'+slidebgcolor+'"></div>')
function start_slider(){
crossrotateobj=dom? document.getElementById("slidedom") : ie? document.all.slidedom : document.slidensmain.document.slidenssub
if (document.layers)
document.slidensmain.visibility="show"
rotatelink()
}
if (ie||dom)
start_slider()
else if (document.layers)
window.onload=start_slider
</script>
--- End code ---
to show useroline like this
hxxp:www.storythai.com/web/useronline.php [nonactive]
[Unknown]:
How much PHP do you know?
-[Unknown]
muayzing:
a little bit
[Unknown]:
If you use ssi_whosOnline('array'), you'll get an array... in there, $return['users'] will be a list of users.
Basically, what you'd want to do is this:
<?php
require('SSI.php');
$return = ssi_whosOnline('array');
$i = 0;
foreach ($return['users'] as $user)
echo '
variableslide[', $i, '] = "', $user['link'], '"';
?>
You won't need to change SSI.php at all.
-[Unknown]
muayzing:
it's not work
i try this
<?php
require('SSI.php');
?>
<html>
<body>
<script language="JavaScript1.2">
var variableslide=new Array()
<?php
$return = ssi_whosOnline('array');
$i = 0;
foreach ($return['users'] as $user)
echo '
variableslide[', $i, ']=[\'', $user['link'], '\']<br>';
?>
var slidewidth=''
var slideheight=''
var slidebgcolor=''
...
but it's not work. i see the blank page
no anything ...
then
only this
<?php
$return = ssi_whosOnline('array');
$i = 0;
foreach ($return['users'] as $user)
echo '
variableslide[', $i, ']=[\'', $user['link'], '\']<br>';
?>
without the javascripts
its show
variableslide[0]=['user1']
variableslide[0]=['user2']
variableslide[0]=['user3']
variableslide[0]=['user...']
i think cause of the number [0]
it should be
variableslide[0]=['user1']
variableslide[1]=['user2']
variableslide[2]=['user3']
variableslide[3]=['user...']
then i try to put to the script
<script language="JavaScript1.2">
var variableslide=new Array()
variableslide[0]=['user1']
variableslide[1]=['user2']
variableslide[2]=['user3']
variableslide[3]=['user...']
var slidewidth=''
var slideheight=''
var slidebgcolor=''
the scripts work to show but not change user...
but with the php in the java scripts
<script language="JavaScript1.2">
var variableslide=new Array()
<?php
$return = ssi_whosOnline('array');
$i = 0;
foreach ($return['users'] as $user)
echo '
variableslide[', $i, ']=[\'', $user['link'], '\']<br>';
?>
var slidewidth=''
var slideheight=''
var slidebgcolor=''
...
its show blank page
? ? ?
Mmm sorry for my bad english
Navigation
[0] Message Index
[#] Next page
Go to full version