473,396 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How do I convert a string integer into a number?

I want to turn the string "100,144" to numbers, to use for
resizeTo(100,144) <--- here. Please advice, or post scriptlette. Thanks

Tony Vasquez
Jul 20 '05 #1
5 23265
In article <dL***************@newsread3.news.pas.earthlink.ne t>, "Tony Vasquez"
<co**********@earthlink.net> writes:
I want to turn the string "100,144" to numbers, to use for
resizeTo(100,144) <--- here. Please advice, or post scriptlette. Thanks


var myString = "100,144";
var myNumbers = myString.split(',');
myWindow.resizeTo((+myNumbers[0]),(+myNumbers[1]));

Also:

http://jibbering.com/faq/#FAQ4_21
--
Randy
Jul 20 '05 #2
Merci, I was hoping to get a quick answer. Thanks for taking the time.

Tony Vasquez
"HikksNotAtHome" <hi************@aol.com> wrote in message
news:20***************************@mb-m03.aol.com...
In article <dL***************@newsread3.news.pas.earthlink.ne t>, "Tony Vasquez" <co**********@earthlink.net> writes:
I want to turn the string "100,144" to numbers, to use for
resizeTo(100,144) <--- here. Please advice, or post scriptlette. Thanks


var myString = "100,144";
var myNumbers = myString.split(',');
myWindow.resizeTo((+myNumbers[0]),(+myNumbers[1]));

Also:

http://jibbering.com/faq/#FAQ4_21
--
Randy

Jul 20 '05 #3
HikksNotAtHome wrote on 06 sep 2003 in comp.lang.javascript:
I want to turn the string "100,144" to numbers, to use for
resizeTo(100,144) <--- here. Please advice, or post scriptlette. Thanks


var myString = "100,144";
var myNumbers = myString.split(',');
myWindow.resizeTo((+myNumbers[0]),(+myNumbers[1]));


or you might concider eval:

var myString = "100,144";
eval("myWindow.resizeTo("+myString+")");

I know, eval is frowned upon,
but it is great executing string stored functionality.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #4
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
HikksNotAtHome wrote on 06 sep 2003 in comp.lang.javascript:
I want to turn the string "100,144" to numbers, to use for
resizeTo(100,144) <-- here. Please advice, or post scriptlette.


var myString = "100,144";
var myNumbers = myString.split(',');
myWindow.resizeTo((+myNumbers[0]),(+myNumbers[1]));


or you might concider eval:

var myString = "100,144";
eval("myWindow.resizeTo("+myString+")");

I know, eval is frowned upon,
but it is great executing string stored functionality.


While eval can be used in this way, I would tend to think that if code
seemed to necessitate the use of eval then that is an indicator if bad
design in the code and that an better approach is available for just the
effort of looking.

In this case the potential use of eval is indicated by the fact that two
numbers have been stored in a comma-separated string. If the numbers had
been stored as a two dimensional array eval use would not be indicated
(and the type conversion would also have become unnecessary).

I suspect that the string data is originating in the value property of
an OPTION element, but that just may not be the best approach to the
problem. If the pairs of numbers were stored in an array of
two-dimensional arrays then the selectedIndex property of the select
could be used to index that array and extract the number values (and the
HTML OPTIONs may not need value attributes at all).

The use of eval is almost never (if not actually never) necessary in
JavaScript. On the _very_ rare occasions that eval use is indicated you
need (at minimum) the element of data unknown at run time. A list of
strings representing comma-separated pairs of numbers does not qualify
as unknown at run time.

Richard.
Jul 20 '05 #5
Thanks guys... :)

Tony Vasquez

"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message
news:bj*******************@news.demon.co.uk...
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
HikksNotAtHome wrote on 06 sep 2003 in comp.lang.javascript:
I want to turn the string "100,144" to numbers, to use for
resizeTo(100,144) <-- here. Please advice, or post scriptlette.

var myString = "100,144";
var myNumbers = myString.split(',');
myWindow.resizeTo((+myNumbers[0]),(+myNumbers[1]));


or you might concider eval:

var myString = "100,144";
eval("myWindow.resizeTo("+myString+")");

I know, eval is frowned upon,
but it is great executing string stored functionality.


While eval can be used in this way, I would tend to think that if code
seemed to necessitate the use of eval then that is an indicator if bad
design in the code and that an better approach is available for just the
effort of looking.

In this case the potential use of eval is indicated by the fact that two
numbers have been stored in a comma-separated string. If the numbers had
been stored as a two dimensional array eval use would not be indicated
(and the type conversion would also have become unnecessary).

I suspect that the string data is originating in the value property of
an OPTION element, but that just may not be the best approach to the
problem. If the pairs of numbers were stored in an array of
two-dimensional arrays then the selectedIndex property of the select
could be used to index that array and extract the number values (and the
HTML OPTIONs may not need value attributes at all).

The use of eval is almost never (if not actually never) necessary in
JavaScript. On the _very_ rare occasions that eval use is indicated you
need (at minimum) the element of data unknown at run time. A list of
strings representing comma-separated pairs of numbers does not qualify
as unknown at run time.

Richard.

Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Tome73 | last post by:
How would I convert this string to an Array? "243, 567, 324, 345" Where each number becomes a new element in that Array. Thanks
3
by: news.hku.hk | last post by:
could you tell me how can i convet a string to integer?? #include <iostream> #include <string> using namespace std; int main(){ int integer; string buffer("123456789");
13
by: Hako | last post by:
I try this command: >>> import string >>> string.atoi('78',16) 120 this is 120 not 4E. Someone can tell me how to convert a decimal number to hex number? Can print A, B, C,DEF. Thank you.
14
by: Drew | last post by:
Hi All: I know I am missing something easy but I can't find the problem! I have a program which reads an integer as input. The output of the program should be the sum of all the digits in the...
20
by: Niyazi | last post by:
Hi all, I have a integer number from 1 to 37000. And I want to create a report in excel that shows in 4 alphanumeric length. Example: I can write the cutomerID from 1 to 9999 as: 1 ---->...
5
by: Bob Homes | last post by:
In VB6, foreground and background colors of controls had to be assigned a single number. If you knew the RGB values for the color, you still had to convert them into the single number accepatable...
7
by: elliotng.ee | last post by:
I have a text file that contains a header 32-bit binary. For example, the text file could be: %%This is the input text %%test.txt Date: Tue Dec 26 14:03:35 2006...
7
by: shellon | last post by:
Hi all: I want to convert the float number to sortable integer, like the function float2rawInt() in java, but I don't know the internal expression of float, appreciate your help!
6
by: sweeet_addiction16 | last post by:
hello Im writin a code in c... can sum1 pls help me out in writing a c code to convert decimalnumber to hexadecimal number.The hexadecimal number generated has to be an unsigned long.
10
by: cmdolcet69 | last post by:
Public ArrList As New ArrayList Public bitvalue As Byte() Public Sub addvalues() Dim index As Integer ArrList.Add(100) ArrList.Add(200) ArrList.Add(300) ArrList.Add(400) ArrList.Add(500)
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.