Doing it that way you can't. One is a string, the other's a number. You'd
have to first convert the fraction into it's decimal representation. You
could prolly write a function to do that. Something like this would work:

        str = '3/8';

        function convertDecimal(str) {
                arr = str.split('/');
                return arr[0] / arr[1];
        }

        alert(convertDecimal(str));




-----Original Message-----
From: Che Vilnonis [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 17, 2007 10:38 AM
To: CF-Talk
Subject: Simple JS math?

Looking to add an integer and a fraction. How do I do this with Javascript?
Thanks, Che!

<script language="JavaScript">
var num = 20;
var frac = "3/8";
var DBWTemp = (num + frac);
document.write(DBWTemp);
</script>





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
CF 8 – Scorpio beta now available, 
easily build great internet experiences – Try it now on Labs
http://www.adobe.com/cfusion/entitlement/index.cfm?e=labs_adobecf8_beta

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:283890
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to