boxhedge
asked on
jquery using csv to produce list with unique href per item
Hi,
I'm trying to adapt a code snippet I had gotten from here.
What I need to achieve is to produce a ul list with data in each li item and a unique href for each item using csv data on the site.
Here's what I have
<section class="tag"><strong>TAGGED IN: </strong><ul><span>item1,n extItems2, anotherIte ms3</span> </ul>
Here's what need to be produced
<section class="tag">
<strong>TAGGED IN: </strong>
<ul>
<li><a href="SameDomainURL/search -results.h tml?item1" >item1</a> </li>
<li><a href="SameDomainURL/search -results.h tml?nextIt ems2">next Items2</a> </li>
<li><a href="SameDomainURL/search -results.h tml?anothe rItems3">a notherItem s3</a></li >
</ul>
Here's the code I've tried to append but doesn't quite work:
What it isn't doing but I need it to is:
1. strip the original csv data just leaving the formatted data.
2. Add the item value as unique value per item to the url href after the ?
Help appreciated...Christmas is nearly here! and I need to finish!
Regards
Lee
I'm trying to adapt a code snippet I had gotten from here.
What I need to achieve is to produce a ul list with data in each li item and a unique href for each item using csv data on the site.
Here's what I have
<section class="tag"><strong>TAGGED
Here's what need to be produced
<section class="tag">
<strong>TAGGED IN: </strong>
<ul>
<li><a href="SameDomainURL/search
<li><a href="SameDomainURL/search
<li><a href="SameDomainURL/search
</ul>
Here's the code I've tried to append but doesn't quite work:
$('.tag span').each(function(){
var currentList = $(this);
var itemsArray = currentList.text().split(",");
//Loop through the array and add a li a href element
$.each(itemsArray , function(index, value) {
var newLI = $("<li>").html($("<a>").html(value).attr('href', '/site-search-results.html?category=').html(value));
currentList.append(newLI);
});
});
What it isn't doing but I need it to is:
1. strip the original csv data just leaving the formatted data.
2. Add the item value as unique value per item to the url href after the ?
Help appreciated...Christmas is nearly here! and I need to finish!
Regards
Lee
Have a look at this project http://code.google.com/p/j query-csv/
ASKER
Thanks but not what I'm after.
Just need this one use and the specific requirements of what I have explained.
If padas or anyone else can be of more help it would be appreciated,
Regards
Lee
Just need this one use and the specific requirements of what I have explained.
If padas or anyone else can be of more help it would be appreciated,
Regards
Lee
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I've requested that this question be closed as follows:
Accepted answer: 0 points for boxhedge's comment #a38716889
for the following reason:
Because it is and expert posted generic answer without really thinking it through. Once an expert posts a single comment it greatly reduces chance of someone elses involvement
Accepted answer: 0 points for boxhedge's comment #a38716889
for the following reason:
Because it is and expert posted generic answer without really thinking it through. Once an expert posts a single comment it greatly reduces chance of someone elses involvement
ASKER
Because I provided the solution and expert posted generic answer without really thinking it through. Once an expert posts a single comment it greatly reduces chance of someone elses involvement particularly in my short timescale.
ASKER
Because I provided the solution and expert posted generic answer without really thinking it through. Once an expert posts a single comment it greatly reduces chance of someone elses involvement particularly in my short timescale.