Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Doing the splits!


Message #1 by Luke Chapman <luke@p...> on Wed, 20 Dec 2000 15:08:25 +0000
on 20/12/00 3:08 pm, Luke Chapman at luke@p... wrote:

> Can anyone help?
> I have the following code:
> 
> 
> 
> 
> function DoThis(item) {
> var more=item.split(".");
> if (more[1]) {
> alert(more[0]+more[1]);
> }
> else {
> alert(more[0]);
> }
> }
> 
> DoThis(form.price.value/10000);
> 
> 
> 
> 
> The problem is, I keep on getting an error of "item.split is not a
> function."
> Cheers
> Luke
> 
> 
> 
> 
It's okay I've sorted it!
I was trying to split a Number not a String.
Code is  now as below:

function DoThis(item) {
    var nan=String(item/10000);
    var more=nan.split(".");
    if (more[1]) {
    alert(more[0]+more[1]);
    }
    else {
    alert(more[0]);
    }
}

DoThis(form.price.value);

Cheers Anyway,
Luke



--- 
NEED TECHNICAL TIPS, TOOLS, AND INSIGHTS?  Is FREE okay?
Visit EarthWeb for the latest in IT Management, Software Development, 
Web Development, Networking & Communications, and Hardware & Systems.  
Click on http://www.earthweb.com for FREE articles, tutorials,
and discussions from the experts.
---
You are currently subscribed to javascript as: $subst('Recip.EmailAddr')
To unsubscribe send a blank email to leave-javascript-$subst('Recip.MemberIDChar')@p2p.wrox.com

  Return to Index