View Full Version : Need help with Split function

05-07-2007, 08:43 PM
Okay this is the entire program and it's working EXCEPT I would like to do a split function for lifesaved variable. Right now the answer is something like 19.734566 I want the .734566 portion everytime so I can multiply by 24 and take that answer and get the .323223 and multiply by min. Unfortuantly everytime I make a change to this thing I lose my output. Please help thanks:thumbsup:

<TITLE>Time since my last smoke</TITLE>
<H4><CENTER>Time since I last smoked</H4>


<SCRIPT type="text/javascript">

function setcountup(theyear,themonth,theday){

//////////CONFIGURE THE COUNTUP SCRIPT HERE//////////////////

//STEP 1: Configure the date to count up from, in the format year, month, day:
//This date should be less than today

//STEP 2: Configure text to be attached to count up
var displaymessage="have passed since my last cigarette!"

//STEP 3: Configure the below 5 variables to set the width, height, background color, and text style of the countup area
var countupwidth='800px'
var countupheight='35px'
var countupbgcolor=''
var opentags='<font face="Verdana" color="black"><small>'
var closetags='</small></font>'

//////////DO NOT EDIT PASS THIS LINE//////////////////

var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
var crosscount=''
var dropret='<br>'

function start_countup(){
if (document.layers)
else if (document.all||document.getElementById)
crosscount=document.getElementById&&!document.all?document.getElementById("countupie") : countupie

if (document.all||document.getElementById)

document.write('<span id="countupie" style="width:'+countupwidth+'; background-color:'+countupbgcolor+'"></span>')


function countup(){
var today=new Date()
var todayy=today.getYear()
if (todayy < 1000)
var todaym=today.getMonth()
var todayd=today.getDate()
var todayh=today.getHours()
var todaymin=today.getMinutes()
var todaysec=today.getSeconds()
var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
paststring=montharray[mo-1]+" "+da+", "+yr

var cigpackcost='4.15'
var dollaramt=(dday*cigpackcost)
var dollarsign="$"
var sincei=" Amount of money I've said since I quit smoking"
var numofcigs='20'
var parta=(dday*numofcigs)
var partz=(numofcigs/24)
var partb=(dhour*partz)
var totalnumofsmokes=(parta+partb)
var saying=" Number of cigarettes not smoked"
var myquitdate="Matthew's quit date 1/2/2007 around 1 am"
var min_saved='11'
var lifesaved=((totalnumofsmokes*min_saved)/1440)
var mylifeback=" days of my life saved"
var length='3.75'
var distance=((totalnumofsmokes*length)/12)
var dang=" feet, if you took all the cigarettes I didn't smoke and laid them end to end that's how long it would be!"
var footballfield=(distance/300)
var wowzers=" number of football fields, with cigarettes laid end to end, thats just since I quit!"
var empire='1454'
var empirecalc=((distance/empire)*100)
var empirewow="% of the height of the Empire State Building, that's to the tip"
var ggate='8981'
var gglen=((distance/ggate)*100)
var gglenwow="% of the length of the Golden Gate"
var mgtar='8'
var oz='0.0352739619'
var oztartotal=(((totalnumofsmokes*mgtar)*oz)/1000)
var tar=(" Ounces, yes OUNCES of tar not put in my lungs")
var co='10.2'
var cototal=(((totalnumofsmokes*co)*oz)/1000)
var cotalk=(" Ounces of Carbon Monoxide, CO, not put in my lungs")
var cart=(dday/10)
var carttext=(" The numbers of cartons")
var est=(totalnumofsmokes/80300)*100
var esttext=("% Estimated percentage of not smoked to smoked")
var plane="2776"
var meandplane=((totalnumofsmokes*length)/plane)
var pl=" how many Boeing 747s I am long now"
var ls=lifesaved

if (document.layers){
document.countupnsmain.document.countupnssub.document.write(opentags+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds "+displaymessage+closetags)
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds "+
displaymessage+dropret+totalnumofsmokes.toFixed(0)+saying+dropret+dollarsign+dollaramt.toFixed(2)+si ncei+
dropret+parseInt(lifesaved)+mylifeback+dropret+distance.toFixed(0)+dang+dropret+footballfield.toFixe d(1)+
wowzers+dropret+empirecalc.toFixed(2)+empirewow+dropret+gglen.toFixed(2)+gglenwow+dropret+meandplane .toFixed(2)+pl+dropret+
oztartotal.toFixed(2)+tar+dropret+cototal.toFixed(2)+cotalk+dropret+cart.toFixed(0)+carttext+dropret +est.toFixed(2)+



<font face="arial, helvetica" size="-2">Check out my blog<br>
<a href="http://sawredsublime.blogspot.com">Matthew</a></font>


05-07-2007, 09:05 PM
Try this.

var lifesaved=((totalnumofsmokes*min_saved)/1440);
var decimalPortion = lifesaved - Math.floor(lifesaved);

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum