Hi,
I have a requirement to convert CSV values entered by user into a Javascript array (of arrays).
No server roundtrip should be made and it should be totally offline/client-side.
If possible, the script should be browser independent.
I have seen a previous post http://www.thescripts.com/forum/thread146456.html but could not find any code level hints.
I know I could use split function and write my own parsing code. But if it is a single line I know the logic can be something like the below, but what if there is a multi-line CSV data in a TextArea?
[CODE=javascript]function jsSplitString(s tringToSplit){
var splitArray = stringToSplit.s plit(",");
for (var i = 0; i < splitArray.leng th; i++){
// add to array
}
}
[/CODE]
-Ramesh.
I have a requirement to convert CSV values entered by user into a Javascript array (of arrays).
No server roundtrip should be made and it should be totally offline/client-side.
If possible, the script should be browser independent.
I have seen a previous post http://www.thescripts.com/forum/thread146456.html but could not find any code level hints.
I know I could use split function and write my own parsing code. But if it is a single line I know the logic can be something like the below, but what if there is a multi-line CSV data in a TextArea?
[CODE=javascript]function jsSplitString(s tringToSplit){
var splitArray = stringToSplit.s plit(",");
for (var i = 0; i < splitArray.leng th; i++){
// add to array
}
}
[/CODE]
-Ramesh.
Comment