473,543 Members | 2,446 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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,14 4) <--- here. Please advice, or post scriptlette. Thanks

Tony Vasquez
Jul 20 '05 #1
5 23275
In article <dL************ ***@newsread3.n ews.pas.earthli nk.net>, "Tony Vasquez"
<co**********@e arthlink.net> writes:
I want to turn the string "100,144" to numbers, to use for
resizeTo(100,1 44) <--- here. Please advice, or post scriptlette. Thanks


var myString = "100,144";
var myNumbers = myString.split( ',');
myWindow.resize To((+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.n ews.pas.earthli nk.net>, "Tony Vasquez" <co**********@e arthlink.net> writes:
I want to turn the string "100,144" to numbers, to use for
resizeTo(100,1 44) <--- here. Please advice, or post scriptlette. Thanks


var myString = "100,144";
var myNumbers = myString.split( ',');
myWindow.resize To((+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.javas cript:
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.resize To((+myNumbers[0]),(+myNumbers[1]));


or you might concider eval:

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

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******** ************@19 4.109.133.29...
HikksNotAtHo me wrote on 06 sep 2003 in comp.lang.javas cript:
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.resize To((+myNumbers[0]),(+myNumbers[1]));


or you might concider eval:

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

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*****@litote s.demon.co.uk> wrote in message
news:bj******** ***********@new s.demon.co.uk.. .
"Evertjan." <ex************ **@interxnl.net > wrote in message
news:Xn******** ************@19 4.109.133.29...
HikksNotAtHo me wrote on 06 sep 2003 in comp.lang.javas cript:
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.resize To((+myNumbers[0]),(+myNumbers[1]));


or you might concider eval:

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

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
273
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
27546
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
41778
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
1463
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 integer that was entered. So, if 353 was entered, the output should be 11.
20
3406
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 ----> 0001 2 ----> 0002
5
8611
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 to the VB6 controls. In VB.NET, you can't set colors that way anymore, now you have to use a "color". There is a way to convert RGB values to a...
7
19196
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 00000000000000001111111111111111 11111111111111111111111111111111 00000000000000000000000000000000 11111111111111110000000000000000
7
6236
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
16887
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
4921
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
7347
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7733
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5883
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5264
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4890
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3388
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3391
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1814
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
963
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.