[thelist] JS Question

Jim McNulty jkmcnulty at mediaone.net
Thu Apr 12 19:32:45 CDT 2001


According to http://www.javascripter.net/faq/convert3.htm#top it's a matter
of which version of JS is being used.  They supply the following function...

function toRadix(N,radix) {
 var HexN="", Q=Math.floor(Math.abs(N)), R;
 while (true) {
  R=Q%radix;
  HexN = "0123456789abcdefghijklmnopqrstuvwxyz".charAt(R)+HexN;
  Q=(Q-R)/radix; if (Q==0) break;
 }
 return ((N<0) ? "-"+HexN : HexN);
}

...as a work-around if the .toString(n) method doesn't work.  This function
seems to work just fine.  You can replace the [  y = x.toString(8);  ] in
your code with [  y = toRadix(x,8);  ].

--Jim


-----Original Message-----
From: thelist-admin at lists.evolt.org
[mailto:thelist-admin at lists.evolt.org]On Behalf Of Salvatore Palmisano
Sent: Thursday, April 12, 2001 12:08 PM
To: thelist at lists.evolt.org
Subject: [thelist] JS Question


My JS isnt what it should be, and I cant seem to figure out why this isnt
working:

<SCRIPT type="text/javascript">
<!--

var x, y;
x = 3;

y = x.toString(8);
document.writeln(y);
document.writeln(x);

-->
</SCRIPT>

to.String(y) is supposed to convert the number to the y format (8 being
octal) isnt it?
Currently the writeln(x) and writeln(y) lines are outputting the same thing.

Did I miss a step?

--Salvatore Palmisano
Chief Information Officer
International Security Solutions, Inc.
spalmisano at usaiss.com


---------------------------------------
For unsubscribe and other options, including
the Tip Harvester and archive of TheList go to:
http://lists.evolt.org Workers of the Web, evolt !





More information about the thelist mailing list