473,806 Members | 2,229 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 23305
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
27567
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
41825
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
3452
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
8657
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 "color", using the Color.FromARGB method. But there doens't seem to be a way to convert the old...
7
19240
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
6273
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
16921
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
4972
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
9596
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10370
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10109
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7649
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6876
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5545
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3849
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.