473,569 Members | 2,617 Online
Bytes | Software Development & Data Engineering Community
+ 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 4168
"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(stri ng)

/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.javas cript:
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.co m> wrote in message
news:Sw******** **********@news fep2-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************ ***********@new s.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
3843
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 "table" insert in my "editable region", have it placed in the "center" of the page.. while it display correctly on my browser, with setting at...
11
1733
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 and others newbie to start with the right foot and to catch the propers tools. Thanx to all Marco
11
4568
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 appreciate any help you can give me. Thanks,
1
3539
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 System.Data.Odbc? thank you in advance..
0
1007
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= Assembly.LoadFile(AppSettings.Root+@"bin\"+assemblyName);
0
1529
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 be set to the field, but instead of that it is set to the form name (company). To avoid it I have to set it manually to the focussed field. How to...
2
3657
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
1399
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 handling the info from there. Sometimes the JS doesn't find the newly inserted tags (divs with id), only when I add the alert command before it. It's...
9
5298
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 this variable is not empty. The message is shown using the "alert()" function. The page works good in almost all the case, but some users have...
24
8196
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 seems to have a (tiny) amount overhead since window itself points to the global object, hence, a circular reference. (From everything I am reading,...
0
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8130
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
7979
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...
0
6284
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...
0
3653
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
3643
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2115
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
1223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
940
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...

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.