Click to See Complete Forum and Search --> : javascript help URGENT
blaster
01-03-2003, 02:12 PM
hi ppl
im a newbie of webdesign and I whould like to know how to make appear centences in the same place in each 3 secs
sorry my bad english but im portuguese
khalidali63
01-03-2003, 02:20 PM
you'd wanna do something like this.
in your html pages body area
<div id="showHideHere"
style="position:absolute;"></div>
then in script section
var flag = true;
write a function say its called
magicWand();
in this function
do this
var obj = document.getElementById("showHideHere");
if(flag){
obj.style.visibility="hidden";
flag = false;
}else{
obj.style.visibility="visible";
flag = true;
}
and last thing set timer to call ur method every 3 secs
setInerval("magicWand()",3000);
and thats all
cheers
Khalid
blaster
01-03-2003, 02:42 PM
ive do all that you tell me to say but nothing apears (maybe ive messed up)
can you explain better or send me something with the html code of all the page with the messages????
khalidali63
01-03-2003, 02:56 PM
what messages and how many messages you want to see appear?
blaster
01-03-2003, 03:03 PM
by the start i whould like to make apear 10 centenses:
joke1
joke2
joke3
joke4
(...)
joke 10
and i wanna add and edit and delete messages when i want
khalidali63
01-03-2003, 03:26 PM
there you go
<script>
var flag = false;
var ctr = 0;
var messages = new Array(
"Joke first 1",
"Joke second 2",
"Joke third 3",
"Joke fourth 4"
);//add as many messages here
onload = magicWand;
function magicWand(){
var obj = document.getElementById("showHideHere");
ctr = (ctr==messages.length)? 0 : ctr;
//alert(ctr)
obj.innerHTML = "";
obj.innerHTML = messages[ctr];
ctr++;
setTimeout("magicWand()",3000);
}
</script>
</head>
<body>
<div id="showHideHere" style="position:absolute;"></div>
Khalid
blaster
01-03-2003, 03:40 PM
tks a lot :D :D