Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 22nd, 2024, 6:47 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Add question
PostPosted: January 2nd, 2016, 10:43 am 
Offline

Joined: May 16th, 2008, 4:50 pm
Posts: 368
Location: Berghem The Netherlands
Opus: Opus Pro 9.75
OS: Windows 10
System: `HP
Hi,
I am working on a HTML5 project where i have to add a number from an other variable.
When i do this by using the add function it sets the number after the existing number in that variable.
When i use the add function with a number (i can choose between number or variable) it works perfect
but i need the variable to add.

When i substract a variable worth is works.
What am i doing wrong?

Kind Regards, Ad

_________________
Opus Pro v9.75
Windows 10 on HP EliteBook i7
http://www.csnmedia.nl


For this message Ad Mulders has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: Add question
PostPosted: January 3rd, 2016, 10:47 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
In JavaScript, the '+' operator is used both for arithmetic (adding) and for strings (concatenation). If one of your variables is a string (text type in Opus) then they are joined not added.

I think perhaps that this shouldn't happen with the Add Action, as personally that action implies arithmetic but in pure code using '+' with always depended on what type of variable JS decides it is handling - so I can understand why it happens.

You either need to specify your variable as a Number in Opus or if coding Type cast accordingly - see this for some more information:

http://www.w3schools.com/js/js_type_conversion.asp

</mack>

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


For this message mackavi has been thanked by : Ad Mulders


Top
 Profile Visit website  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group