473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

split() function is acting up!

21
i have some JavaScript code that gets a variable from an input field, then parses it into a float. That all goes OK, but after that it gets weird: i put it variable.split("."); and FireBug gives me this error:
Expand|Select|Wrap|Line Numbers
  1. timeSpanFull.split is not a function
Here is a snippet of the code:
Expand|Select|Wrap|Line Numbers
  1. timeSpanFull = parseFloat(fetchById('timeSpan').value);
  2. timeSpan = timeSpanFull.split(".");
I've looked at a few examples online, and cross checked with those, but came up with nothing. I also looked for hidden characters, but came up with nothing again.

Thanks in advance,
Naurus
Jul 31 '07 #1
2 1434
gits
5,390 Expert Mod 4TB
hi ...

when using the split-function the value must be a string-value ... so you cannot use split() with a 'number-type'. but you can use:

Expand|Select|Wrap|Line Numbers
  1. // floating number
  2. var number = 2.3;
  3.  
  4. // split the parts of number
  5. var splitted_number_array = new String(number).split('.');
kind regards
Jul 31 '07 #2
naurus
21
Thank you so much! i really wish that some of the online tutorials would've said that.

hi ...

when using the split-function the value must be a string-value ... so you cannot use split() with a 'number-type'. but you can use:

Expand|Select|Wrap|Line Numbers
  1. // floating number
  2. var number = 2.3;
  3.  
  4. // split the parts of number
  5. var splitted_number_array = new String(number).split('.');
kind regards
Jul 31 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: SL_McManus | last post by:
Hi All; I am fairly new to Perl. I have a file with close to 3000 lines that I would like to split out in a certain way. I would like to put the record type starting in column 1 for 2 spaces,...
4
by: Henry Chen | last post by:
Hi, I have a string that needs to be parsed into the string. The separator is not char. It is something like " at ". With current string.Split function, it doesn't work. Is there any exist...
5
by: Vamsi | last post by:
Hi, I am trying a basic opearation of splitting a multiline value to an array of single lines(Actually making Address into AddressLine1, AddressLine2). I used Environment.NewLine in split, I...
10
by: mb | last post by:
I was wondering if there is an easy, more useful Split function that will split with a string delimiter like "<>" or "////"?
4
by: Itzik | last post by:
can i split this string string str = "aa a - bb-b - ccc" with this delimiter string del = " - " i want recieve 3 items : "aa a" , "bb-b" , "ccc"
3
by: Ben | last post by:
Hi I am creating a dynamic function to return a two dimensional array from a delimeted string. The delimited string is like: field1...field2...field3... field1...field2...field3......
5
by: sck10 | last post by:
Hello, I have a list of email addresses that I need to send email to from the website. I am trying to use the "Split" function to get all the To's and then use the uBound function for the...
1
by: Jeff Williams | last post by:
I looking for an example of how to do a 3 pane split window. I need a left pain with a treeview, and 2 right panes as a listviews. If you know a site which has an example could you post a link...
1
by: John | last post by:
Hi I have written a Split function which in turn calls the standard string split function. Code is below; Function Split1(ByVal Expression As String, Optional ByVal Delimiter As String = " ",...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.