I have a text box that the contents change on page reload, but what I was wondering is how to make it change after a specified amount of time. Is this possible without flash?
+1
A:
setInterval('changeTextFunction()',1000);
Second param, 1 sec = 1000.
Babiker
2010-06-18 15:59:30
+1
A:
For changing the text in a textbox you can
txtFld = document.getElementById("yourTextBox");
txtFld.value = "New value";
To set a timer, like a countdown timer, you could use a variation of something like this:
<script>
<!--
//
var milisec=0
var seconds=30
document.counter.d2.value='30'
function display(){
if (milisec<=0){
milisec=9
seconds-=1
}
if (seconds<=-1){
milisec=0
seconds+=1
}
else
milisec-=1
document.counter.d2.value=seconds+"."+milisec
setTimeout("display()",100)
}
display()
-->
</script>
TheGeekYouNeed
2010-06-18 15:59:45
+2
A:
Copy and paste this code in to a html file and check it out, should be easy enough for you to edit to fit your own needs. Enjoy :o)
<html>
<head>
<script type="text/javascript">
//Change these messages to what ever you would like to display in the textbox
//You can add or remove any as you see necessary
var messages = new Array(
"Hello",
"there",
"my",
"name",
"is",
"Chief17!"
);
var i = 0;
function changeText()
{
document.getElementById("tb").value = messages[i];
if(i < messages.length -1)
{
i++;
}
else
{
i = 0;
}
}
</script>
</head>
<!--Change the 1000 to how long you want to wait in between message changes (1000 is 1 second)-->
<body onLoad="setInterval('changeText()',1000)">
<input type="text" id="tb" />
</body>
</html>
Chief17
2010-06-18 16:45:26