SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Apr 2010
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jquery csv to table

    I am using this jquerycsvtotable - jQuery CSV to Table reads in CSV or TSV data (both can be saved from Excel) and generates an HTML table - Google Project Hosting to generate an html table and populate it with data from a csv. This works great, but now I want to be able to add images in each row.

    How can i modify the javascript to show an image if the path is entered into the csv file?

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Modify the function CSVToTable in the file jquery.csvToTable.js

    Your new code to see if the item is an image URL and if so print an image tag should start around line 131.

  3. #3
    SitePoint Member
    Join Date
    Apr 2010
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks. I don't know how to write js for that, do you have any resources you can point me to, or what the search term I should use?

  4. #4
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by draivika View Post
    thanks. I don't know how to write js for that, do you have any resources you can point me to, or what the search term I should use?
    You need nothing but the most basic language syntax, so what you need is a book on learning JavaScript in general.

  5. #5
    SitePoint Member
    Join Date
    Apr 2010
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Getting closer I think. some help clarifying what i'm doing is a great help:

    the lines in question:

    $.each(items, function(itemCount, item) {
    tableHTML += '<td class="' + options.tdClass + '">' + item + '</td>';
    });

    I need to insert an "if" that looks for an image url and replaces with imag tag. Not sure where that goes exactly.
    I know I want to show the image like this:
    $('<img></img>') .attr('src', 'images/' + image_url)

    any further help is appreciated folks.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •