简体   繁体   中英

Dropdown with image and text together in Asp.net 3.5 and jquery

I've been given a task to make a dynamic drop down which takes it's data[image and value id] from table. I am wondering if any of you came across this scenario or if any one can help me out in this I need help in concept and coding. Definitely any help is appreciated. I see the example in jquery here is the link:

http://www.marghoobsuleman.com/jquery-image-dropdown

something like this but data is coming from table.

If you use the plugin that you found in the link, then basically what you will want to do is create the dropdown dynamically based on the table content. Without having more details of how your table is structured I can't give you exact details, but something like this should get you close (I'm going to assume there is a drop-down element already on the page somewhere called "select", and your table is called "table" with the image in field 0, and the text in field 1) Note: This hasn't really been tested.

var options = "";
$("#table tr").each(function() {
    var imagePath = $(this).find("td:eq(0) img").attr("src");
    var title = $(this).find("td:eq(1)").text();
    options += '<option value="'+title+'" title="'+imagePath+'">'+title+'</option>';
});
$("#select").html(options);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM