?
Solved

Rolling text

Posted on 2002-04-14
3
Medium Priority
?
2,111 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 300 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

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 …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…
Suggested Courses

800 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