Reputation: 3406
Okay, this is quite related to my previous quesion, but still (so you don't have to travel to that page..)
I have a string in the format
ItemName1:Rate1:Tax1_ItemName2:Rate2:Tax2:_ItemName3:Rate3:Tax3_ItemName4:Rate4:Tax4
the user will pass 4 args, first will tell which element to take, when this list is split by _
, and other 3 will tell the new values of items.
For example, if user passes 2, Denim Jeans, 399.00, 14.34
. The original string would become
ItemName1:Rate1:Tax1_ItemName2:Rate2:Tax2:_Denim Jeans:399.00:14.34_ItemName4:Rate4:Tax4
First split at _
, get the element at index 2
(the value user supplied), and then split that element at :
and then replace those items with the value supplied.
I got around a lot, here is the jsfiddle for that. But I am just stuck at the last part that will do the appropriate concatenation.
Can help please help me make this last function?
Edit : updated the fiddle!
Upvotes: 0
Views: 1527
Reputation: 737
couple of things here...
Not sure why you are taking list as a string. it would have been better you have used a json object.
and in your example you are getting the 2nd string in the required format..so it doesn't make sense to split it and join again.. you just need to replace the array item with the argList
here is the modified jsfidle. hope i understood your problem right. tell me if there are any gaps... http://jsfiddle.net/k87Zw/5/
Upvotes: 1