473,465 Members | 1,934 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to have alert("1"+1) return 2 instead of 11 ??

How can I convert a string object with a vallid number in it to an integer
value ?

Ton den Hartog

Jul 20 '05 #1
5 4166
"Ton den Hartog" <to**@xs4all.nl> writes:
How can I convert a string object with a vallid number in it to an integer
value ?


There are many ways:

The shortest, prefix plus: +string
Convert to Number explicitly: Number(string)
Parse as integer or float: parseInt(string,10) or parseFloat(string)

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

"Ton den Hartog" <to**@xs4all.nl> wrote in message
news:bg**********@www-2.dev.ict.nl...
How can I convert a string object with a vallid number in it to an integer
value ?

answer = parseInt("1") + 1; // this returns 2


Jul 20 '05 #3
Ton den Hartog wrote on 07 aug 2003 in comp.lang.javascript:
How can I convert a string object with a vallid number in it to an
integer value ?


s = "123"
resultaat = 1 * s
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #4
Thanks !

NB where do I find the newsgroup FAQ ? Will be more than happy to read it !

Ton

--
Computer museum tonh: http://www.tonh.net
GGGallery: http://www.tonh.net/gggallery
- GGGallery on Tucows with a 4 cows rating !
"owen" <sp**@spam.com> wrote in message
news:Sw******************@newsfep2-win.server.ntli.net...

"Ton den Hartog" <to**@xs4all.nl> wrote in message
news:bg**********@www-2.dev.ict.nl...
How can I convert a string object with a vallid number in it to an integer value ?

answer = parseInt("1") + 1; // this returns 2

Jul 20 '05 #5
In article <3f***********************@news.xs4all.nl>, "Ton den Hartog"
<to**@xs4all.nl> writes:
Thanks !

NB where do I find the newsgroup FAQ ? Will be more than happy to read it !

Ton


http://www.jibbering.com/faq/
And specifically, with regards to your question:
http://www.jibbering.com/faq/#FAQ4_21
--
Randy
All code posted is dependent upon the viewing browser
supporting the methods called, and Javascript being enabled.
Jul 20 '05 #6

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

Similar topics

17
by: black tractor | last post by:
HI there.. l was just wondering, if l place a "table" in the "editable region" of my template, will the text, graphics placed inside the this "table" MOVE BY ITSELF?? l mean, recently l had a...
11
by: Ux | last post by:
Hi I'm a newbie at JS and I'd like to know, from the expert JS-er, which are the "things" they consider a *must have* (or known/visited/read...) for a professional JS developer. This will help me...
11
by: Alistair Saldanha | last post by:
I'm looking for the event that is fired by Internet Explorer to an "alert": <SCRIPT> Alert("You already have a session open") </SCRIPT> The event would be webBrowser.Document.???? Much...
1
by: matt (ziba) | last post by:
using the Microsoft.Data.Odbc component instead of System.Data.Odbc how do u get a row count using the Microsoft.Data.Odbc.OdbcDataReader ?? and is it best to use Microsoft.Data.Odbc OR...
0
by: Daniel | last post by:
hi ng, i want to invoke a dynamically created object with reflection, like: public static object createInstance(string classname, string assemblyName) { object obj=null; Assembly assembly=...
0
by: AA Arens | last post by:
I made a find record button on my form "company" (with field for name, phone nr, e-mail etc.). I expect that when I focus on one of the field, the "look in" of the find-record dialog box should...
2
by: Boki | last post by:
Hi All, // code start alert("document.all.txtbox"+valueA+".value") // end code could you please advice, can it show the value of txtbox ?
1
by: moho | last post by:
Hi, I've been struggling with AJAX for a while and notice that if I add the alert("xxx") in my code it always makes the code work. I'm using divs where I put the output from the server and then...
9
by: Tonio Tanzi | last post by:
I have an asp page with this tag <body onLoad="show_msg('<%=error_msg%>');"> where "show_msg" is a javascript function that shows the message contained in the asp variable "error_msg" only if...
24
by: Jeremy J Starcher | last post by:
While reading c.l.j, I've noticed that some people prefer and indeed even recommend the use of "window.alert()" over "alert()". I can't find any technical reason to make this distinction, and...
1
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...
0
Oralloy
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,...
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...
1
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
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,...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.