Solved

Rolling text

Posted on 2002-04-14
3
2,098 Views
Last Modified: 2012-05-04
I am new to javascripting. I want a text box with the text in the box in rolling style.

Kash
0
Comment
Question by:PraKash
  • 2
3 Comments
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 100 total points
ID: 6940453
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
 

Author Comment

by:PraKash
ID: 6940991
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
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6941850
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now