# How can I scroll a message in a text box? (HTML/JavaScript)



## NameTooLong (Dec 26, 2002)

I have a random tips script and I want the script to scroll the message if it is too long... scrolling to the left should be fine... maybe even bounce from left to right...

Here is an example of the script I'm using.


```
<html>
  <head>
    <script type='text/javascript'>
      var tip=new Array()
      // "\" escapes the next character in the line.
      tip[0]="Always use Amorer's Hammers to repair items\.\.\. it is much cheaper and helps you level up faster\."
      tip[1]="Go as long as you can without meditating\.\.\. you'll get attributes faster but won't get a high level\."
      tip[2]="Try not to use sources of fast travel \(e\.g\. Silt Strider\) and you will get more experience from kills along the way and just running\."
      tip[3]="If you want to kill someone... take something and wait until they hit you, it will be self-defense and you are only fined for theft\."
      tip[4]="Never store your items in a container\.\.\. some have owners and all items put in them will be considered stolen when removed\."
      tip[5]="The farther you fall\.\.\. the faster you level up in acrobatics\.\.\. unless\, of course\, you die\. \:\-\)"

      function random_tips(){
      	var rt=Math.floor(Math.random()*tip.length)
      	document.randomform.randombox.value = tip[rt]
      }
      window.onload=random_tips
    </script>
  </head>

  <body>
    <form name='randomform'>
      <input type='text' name='randombox' value='You do not have JavaScript enabled, you cannot see the random tips.'>
      <input type='button' value='Next' onclick='random_tips()'>
    </form>
  </body>
</html>
```


----------



## bassetman (Jun 7, 2001)

I don't know for sure if any of these will do exactly what you want, but check it out.
http://www.ukauctionhelp.co.uk/marquee.php


----------



## NameTooLong (Dec 26, 2002)

Sorry, that is not a HTML 4.01 tag and it can't scroll text inside of a text box...


----------



## Shadow2531 (Apr 30, 2001)

You could use a "textarea" for the random box instead of a text input.


I haven't tried it or looked at the link above, but that's what I would try.


----------



## Shadow2531 (Apr 30, 2001)

all I did is change your randombox input to the following and it looks good to me.

That's up and down scroll though.


----------



## NameTooLong (Dec 26, 2002)

I've already made it using a text area but a text area won't fit into the design in this case... see The Morrowind Gateway. It's near the top under the header. Styled to fit the page.


----------



## Shadow2531 (Apr 30, 2001)

Yeh, I saw it. I edited your tips.htm. The textarea is the same size as your input box you are using now. The only difference being that the textarea has a scrollbar.


----------



## NameTooLong (Dec 26, 2002)

Oh, sorry, didn't read the code the first time... I just knew I didn't want a text area... I tried it and IE works fine but Firebird can't display the scrollbar that small.

I still think a scroll affect would be perfect, much like the status bar scrolling text effects. Just set up an if statement so that if it is so many characters long it scrolls... I dunno, I'm very basic with JavaScript but I do think it's possible.


----------



## Shadow2531 (Apr 30, 2001)

IC

As always, I'll give it a shot.


----------



## Shadow2531 (Apr 30, 2001)

What about this?

http://javascript.internet.com/scrolls/1-cool-textbox-scroller.html

Just add your code to it and make sure the variables match the ones in the script.

You will have to modify it a little bit, but that should work.

http://javascript.internet.com/scrolls/


----------

