/    Sign up×
Community /Pin to ProfileBookmark

Javascript Ticker

Hi – I have this ticker that I have managed to get database driven – the only problem is that I would like to be able to create hyperlinks on the ticker to direct me to the news page. The ticker uses an input box that has been style’d so it doesn’t look like an input box. Whats the best way to adapt the ticker so that I can get some hyperlinks in there.

Thanks

Code:

$q = mysql_query (‘SELECT * FROM news’);
while ($row = mysql_fetch_array($q)){
$array = addslashes($row[‘intro’]);
$php_array[] = $array;
}
/*

echo ‘<pre>’;
print_r ($php_array);
echo ‘<pre>’;*/

echo “<script language=’JavaScript’>n”;
echo “var line=new Array();n”;
foreach($php_array as $key => $value)
{
echo “line[$key] = “$value”;”;
}
echo ‘var longestmessage=1
for (i=2;i<line.length;i++){
if (line[i].length>line[longestmessage].length)
longestmessage=i
}
lines=line.length-1
if (document.all||document.getElementById){
document.write(“<form name=”bannerform”><input type=”text” name=”banner” size=”313″ class=”level3″ style=”border: none; height: 27px; font-size: 12px;padding-right:4px; line-height: 27px;” onfocus=”blur()” ></form>”);
}
temp=””
nextchar=-1;
nextline=0;
cursor=”*
function animate(){
if (temp==line[nextline] & temp.length==line[nextline].length & nextline!=lines){
nextline++;
nextchar=-1;
document.bannerform.banner.value=temp;
temp=””;
setTimeout(“nextstep()”,2000)}
else if (nextline==lines & temp==line[nextline] & temp.length==line[nextline].length){
nextline=1;
nextchar=-1;
document.bannerform.banner.value=temp;
temp=””;
setTimeout(“nextstep()”,2000)
} else {
nextstep()
}
}
function nextstep(){
if (cursor==”*
“){
cursor=”*“}
else if (cursor==”*
“){
cursor=”*“}
else if (cursor==”*
“){
cursor=”*“}
else if (cursor==”*
“){
cursor=”*”}
nextchar++;
temp+=line[nextline].charAt(nextchar);
document.bannerform.banner.value=temp+cursor
setTimeout(“animate()”,25)
}
if (document.all||document.getElementById)
window.onload=animate’;
echo “</script>n”;

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@FangDec 06.2007 — Change the [I]input[/I] for a [I]div[/I]
×

Success!

Help @FamilyMan spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...