+ Start a Discussion
praveen kumar 267praveen kumar 267 

Please help me out on the Javascript

var k=[Ramesh~22~Hyderbad,Suresh~34~Bangalore,Rakesh~36~pune];
i want split below like this

var empname contains list of (Ramesh,Suresh,Rakesh)
var empno   contains list of (22,34,36)
var location contains list of (Hyderbad,Bangalore,pune)
Best Answer chosen by praveen kumar 267
Keyur  ModiKeyur Modi
Hi,
 you can split it by ~ and ,
var string str0=k.spilt(',');
for(j=0;j<str0.size();j++){
var string[] str= k.spilt('~');
for(i=0;i<string.length();i+3){
var EmpName=str[i]
}
for(i=1;i<string.length();i+3){
var EmpNo=str[i]
}
for(i=2;i<string.length();i+3){
var location=str[i]
}
}
please let me know if this will help,

Thanks,
Keyur Modi

All Answers

Keyur  ModiKeyur Modi
Hi,
 you can split it by ~ and ,
var string str0=k.spilt(',');
for(j=0;j<str0.size();j++){
var string[] str= k.spilt('~');
for(i=0;i<string.length();i+3){
var EmpName=str[i]
}
for(i=1;i<string.length();i+3){
var EmpNo=str[i]
}
for(i=2;i<string.length();i+3){
var location=str[i]
}
}
please let me know if this will help,

Thanks,
Keyur Modi
This was selected as the best answer
Rahul SharmaRahul Sharma
Avoid posting duplicate posts unnecessarily!