Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Experts,
I have a string in java script like
JavaScript
var str="ID:1:A;ID:2:B;ID:3:A;ID:4:c;ID:5:D"


Now i know only ID:2 i want to get the option present in front of ID:2 ie, :B

can any one please help me to solve this issue using java script?

thanks in Advance
(Keerthi kumar)
Posted
Updated 23-Apr-15 2:58am
v3
Comments
Maciej Los 23-Apr-15 8:59am    
You should split string by ";" and then by ":". That's all!
Keerthi Kumar(Andar) 23-Apr-15 9:05am    
how? i don't want to use for loop because...it may take time.
if i split by ";" i will get ID:2:B in first index after that
I will get dynamically ID:number by this i should get the option ie, A or B or C etc
John C Rayan 23-Apr-15 9:07am    
Are you familiar with JQuery? Try JQuery.
Keerthi Kumar(Andar) 23-Apr-15 9:11am    
could you please give me a hint?
John C Rayan 23-Apr-15 9:45am    
Check my solution.

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900