Return an array of values from toggled images in jquery

I am using a jquery post to return an xml dataset. I was originally using drop down form controls to filter the data as it was returned.

Now I want to be able to display a list of manufacturer icons and then have the user click on those to toggle them on and off.

$('#sho').click(function() {
    if ($(this).hasClass('highlight')){
    } else {

Currently I have the toggle code in place so that the image just gets a box around it when it is clicked. I am also setting the ALT attribute with a value. I want to be able to gather all the alt attribute that have values and pass them to my jquery post.

function loadXML(so) {
<!-- Clothing Version -->
timestamp = Math.round(new Date().getTime() / 1000);

$("#wrapper").html('<div id="load"><img src="" alt="loading" align="center"  /></div>');
    productGroup: "hel",  
    sortOrder: so,
    qt: "group",
    ts: timestamp,
    manufacturer:$("input:checkbox[name='man[]']:checked").map(function() {
        return $(this).val();
    }).get()}, <----- I need to replace this section of code
    function(xml) {
        $('#results').html("Your Product was not found");


Ultimately the value that gets passed to the manufactuer variable is simply a comma separated list of values such as ara,sho,sha,ara

Does anybody have any thoughts on this please. I have tried using the .each() method and have managed to get it to alert all the positive values but I cannot concatenate them into a string.

            var id = $(this).attr("id");
            var altVal = $(this).attr("alt");
            if (altVal != '') {
                alert($('img#' + id).attr('alt'));

As always help is much appreciated.

Cheers Graham


try this..

manufacturer : function() {
    var ar= new Array();
   return ar.join(",");

jsFiddle to show uses of push and and join

Need Your Help

how can i know that a stack is empty if i use this method to pop elements?

c stack

I'm trying to implement a stack in C using singly linked lists, it all works fine as long as the stack is non-empty. Once empty my pop method never detects that its empty but gives some random valu...

What is the best way to get a content object's position in the parent? Plone 4

indexing position plone catalog plone-4.x

I am traversing folders with content items within them. I use the portal_catalog to get brains searched on certain paths. The brains have access to metadata, and brain.getObject() will return the

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.