Forum Moderators: open
I wanted to create an effect of a textbox that changes content fast.
For some reason it only displays the last line: "right" instead of creating a nice content changing effect.
For a preview of this effect, go to:
Below is just an example.
I have like thousands of lines to display instead of the "whatever" and "right". This example might seem to be very stupid but I have a real world application for it. What do I have to do to make it work?
Please help me out! Thanks in advance!
<form name="form1">
<input name="txtOne" type="text" size="100">
<script language="JavaScript">
document.forms[0].txtOne.value = "whatever";
document.forms[0].txtOne.value = "what";
document.forms[0].txtOne.value = "yeah";
document.forms[0].txtOne.value = "right";
</script>
</form>
[edited by: jatar_k at 3:13 pm (utc) on Oct. 5, 2005]
[edit reason] removed url [/edit]
event = new Date("Sep 29 2001 00:00:01");
That date is in the past (by my watch). Try changing the year to 2004. You'll find that the script does work.
It may be better, afterwards, to change your referencing to a stricter style. eg:
document.form1.days.value = days;
// to
document.forms['form1'].elements['days'].value = days;
Sorry for the confusion.
The script that I am talking about is:
<form name="form1">
<input name="txtOne" type="text" size="100">
<script language="JavaScript">
document.forms[0].txtOne.value = "whatever";
document.forms[0].txtOne.value = "what";
document.forms[0].txtOne.value = "yeah";
document.forms[0].txtOne.value = "right";
</script>
</form>
The website link is only for visualizing changing content effect. Nothing to do with my script actually. ;-)
Sorry for that.
<form name="form1">
<input name="txtOne" type="text" size="100">
<script language="JavaScript">
var values = [ 'whatever', 'what', 'yeah', 'right']
var iCurrValue = 0 var delay = 1000
function changeValue()
{
document.forms[0].txtOne.value = values[iCurrValue++]
setTimeout("changeValue()",delay)
}
</script>
</form>
<form name="form1">
<input name="txtOne" type="text" size="100"></form>
<script language="JavaScript">
var values = [ 'whatever', 'what', 'yeah', 'right'];
var iCurrValue = 0;
var delay = 1000;
changeValue();
function changeValue()
{
document.forms[0].txtOne.value = values[iCurrValue++];
setTimeout("changeValue()",delay);
}
</script>