Hi all,
The following JS function gives a runtime error - 'Error myButton is
undefined' when the function tries to call itself.
The function basically tries to [simply] animate a buttons text to show
the user that something is happening . . .
function buttonText(myButton) {
var A='/', B='-', C='\\', D='|';
var Text=eval(myButton+'.value');
switch (Text) {
case '|':
eval(myButton+'.value=A');
break;
case '/':
eval(myButton+'.value=B');
break;
case '-':
eval(myButton+'.value=C');
break;
default:
eval(myButton+'.value=D');
break;
}
setTimeout('buttonText(myButton)',150);
} 4 1276 al******@nts-graphics.co.uk wrote: Hi all,
The following JS function gives a runtime error - 'Error myButton is undefined' when the function tries to call itself.
The function basically tries to [simply] animate a buttons text to show the user that something is happening . . .
function buttonText(myButton) { var A='/', B='-', C='\\', D='|'; var Text=eval(myButton+'.value'); switch (Text) { case '|': eval(myButton+'.value=A'); break; case '/': eval(myButton+'.value=B'); break; case '-': eval(myButton+'.value=C'); break; default: eval(myButton+'.value=D'); break; } setTimeout('buttonText(myButton)',150); }
Hi,
I think in your call:
setTimeout('buttonText(myButton)',150);
button doesn't contain the original value (a reference to a button??).
You better rewrite your code and pass a number of string to the function.
setTimeout('buttonText(1)',150);
Of course you'll have to change the function too, so it understands 1.
when receiving 1, set 2 in the timeout-call.
etc.
Regards,
Erwin Moller
function buttonText(button_id)
{
var b = document.getElementById(button_id);
if (b)
{
switch (b.value)
{
case '|' :
b.value = '/';
break;
case '/' :
b.value = '-';
break;
case '-' :
b.value = '\\';
break;
default :
b.value = '|';
}
}
}
setTimeout('buttonText("button1")', 150);
<input id="button1"...../>
OK, had a little fun here. See if there's anything you can use. =:o
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>untitled</title>
<style type="text/css">
..button {
width: 60px;
font: bold 14px tahoma;
color: #060;
background: #efe0b8;
}
</style>
<script type="text/javascript">
var B =
{
timer : null ,
active : false ,
curr : null ,
nglyph : 0 ,
glyphs : ['|','/','--','\\']
}
function butspin(but)
{
init();
if (!B.active && but != B.curr)
{
but.origValue = but.value;
B.active = true;
B.curr = but;
B.timer = setInterval(animate, 100);
}
else B.curr = null;
}
function animate()
{
B.curr.value = B.glyphs[B.nglyph++ % 4];
}
function init()
{
if (B.timer)
{
clearInterval(B.timer);
B.active = false;
}
if (B.curr && B.curr.origValue)
B.curr.value = B.curr.origValue;
B.nglyph = 0;
}
onunload = init;
</script>
</head>
<body style="margin:100px;">
<hr />
<form>
<input id="button1"
class="button"
type="button"
value="foo"
onfocus="this.blur()"
onclick="butspin(this)" />
<input id="button2"
class="button"
type="button"
value="feh"
onfocus="this.blur()"
onclick="butspin(this)" />
<input id="button3"
class="button"
type="button"
value="hah"
onfocus="this.blur()"
onclick="butspin(this)" />
<input
class="button"
type="button"
value="stop"
style="color:#600;margin-left:5px;"
onfocus="this.blur()"
onclick="init()" />
</form>
<hr />
</body>
</html>
Thanks guys, the last solution did the trick :-) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Bob Bamberg |
last post by:
Hello All,
I have been trying without luck to get some information on debugging
the Runtime Error R6025 - Pure Virtual Function Call. I am working in
C++ and have only one class that is derived...
|
by: Nathan Bloom |
last post by:
Hi,
I have a secured database that runs fine on the computer the database is
installed on. I have several workstations with access runtime installed
that also need access to the database. ...
|
by: Paul |
last post by:
I'm hoping someone can help me with the problem.
I have a database where the default value for a date field in a table is
=date()
This works perfectly in my table and on my form. But when I...
|
by: Markus Ewald |
last post by:
I'm just experimenting around with the VisualC++ 2005 Express Edition Beta
and found some strange behavior for which I can't seem to find a workaround.
What I've done is set up two static library...
|
by: Kirk |
last post by:
I'm trying to use a Web Service to be a Remoting client of an existing
..NET 2.0 server. But I get the following error when I try to use
System.Runtime.Remoting.Channels.Http in my WebService. ...
|
by: zfraile |
last post by:
I'm getting this error from the JIT compiler at runtime, but only on my boss'
machine, not my development machine. I believe the error is generated from a
call to an Excel object, but I can't tell...
|
by: Yelena Varshal via AccessMonster.com |
last post by:
Hello
We have a shortcut for our MS ACCESS application that uses a /Runtime switch
because we may have some users that use Runtime. The application worked fine
in Access 2000 and was tested with...
|
by: Norman Diamond |
last post by:
A project depends on VC runtime from Visual Studio 2005 SP1, and DotNet
Framework 2. Options are set in the setup project properties, so if these
two dependencies are not already installed then...
|
by: Jim Armstrong |
last post by:
Hello all -
This is driving me crazy. I have a table called tblClients - very
simple, has the following fields:
taxID (PK)
ClientName
SalesName
The main form of my application allows a...
|
by: BL3WC |
last post by:
Hi,
I'd created a MDE under Access 2003. It is now under testing stage. Some of the users will use Access 2003 runtime and some will use Access 2007 runtime to run this MDE. I installed the...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |