• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2113
  • Last Modified:

Rolling text

I am new to javascripting. I want a text box with the text in the box in rolling style.

Kash
0
PraKash
Asked:
PraKash
  • 2
1 Solution
 
COBOLdinosaurCommented:
If this is not what you are looking for, I guess I misunderstood the question.  Perhaps a little more detail would help.

This will work cross brower.  If you Use it just for Netscape you can remove
the style entry from the input that is just for IE and without it the scroll
will start in the middle of the text box.

Your message goes in the display_text variable.  just replace the text
I have there.

The current width of the text box is 50.  If you want to change it there
are 3 spots to make the change.  The size value on the input the var
declaration: var place = 50;   and down in the fucntion whre it says
place = 50;

I put it in a table for positioning, but you should be able to put it
anywhere on the page with whatever positioning method you prefer.

<html>
<head>
<title> scrolling text box </title>
<script language="JavaScript">
<!--

   var display_text  = "The text of your message goes into one"
   + " long variable.  I am not sure how long the maximum is, "
   + " but I am sure there must be one somewhere!!  "
   var display_text;
   var place;
   var where;
   var out = " ";
   var place = 50;
   function scrollText()
   {
      for (where = 0; where < place; where++)
      {
         out += " ";
      }
      if (place >= 0)
      {
         out += display_text;
      }
      else
      {
         out = display_text.substring(-place,display_text.length);
      }    
      document.scroll_form.field.value = out;
      out = " ";
      place--;
      if (place < -(display_text.length))
      {
         place = 50;
      }
      setTimeout('scrollText()',100)
   }
// -->
</script>

<body onLoad="scrollText()">
<br /><br />< />
<table align="center" border=0 cellpadding=0 cellspacing=0><tr><td>
<form name="scroll_form">
<input style="font-family:monospace" type="text" name="field" size="50">
</form>
</td></tr></table>
</body>
</html>


Let me know if you need more info.

Cd&
0
 
PraKashAuthor Commented:
Cd&, hey dude thats what I want but in a different manner. Like I want the text to move from bottom to the top. I want a bigger text box where in the text keeps moving and the text should stop when the mouse goes on it.

And hey thanx for ur help. I like cobol too. I was working in mainframe some time ago.

Kash
0
 
COBOLdinosaurCommented:
I don't think you are going to find a way to make that happen in a textbox.  A textbox is limited to a single line.  You can change the text string in it, which is what the code I posted does.  I just appears to be moving, there is no actual repositioning, just a re-writing of the string.

What you need is a scroller with the box styled to look like a textbox, but it will not be a functional textbox.

The styling would look like this:

<STYLE>
   .textBOX {border:2px inset black;height:20;width:150;font-family:arial;
             font-size:10pt;
             border-right:1px solid #dddddd; border-bottom:1px solid #dddddd}
</STYLE>
with the height and width set to whatever you want.

Then you should be able to use one of the scrollers here:
http://www.dynamicdrive.com/dynamicindex2/index.html

Cd&
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now