1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

JQuery and XML to create table in HTML

Discussion in 'jQuery' started by Triel, Feb 3, 2014.

  1. #1
    Hi -

    First off thank you to anyone who can help me.

    I am trying to create a HTML table using JQuery and I can't seem to get it right. The table is just a 3 column table that has a background image and a company logo in it. Here is what I have so far.

    Here is part of the XML:
     <Partners>
        <ID>3</ID>
        <backgroundURL>/images/BackgroundY.png</backgroundURL>
        <hrefURL>#http://www.andis.com/#</hrefURL>
        <imgURL>/images/p01a.png</imgURL>
        <company>Andis</company>
      </Partners>
      <Partners>
        <ID>4</ID>
        <backgroundURL>/images/BackgroundY.png</backgroundURL>
        <hrefURL>#http://www.aurorahealthcare.org/#</hrefURL>
        <imgURL>/images/p24a.png</imgURL>
        <company>Aurora Healthcare</company>
      </Partners>
      <Partners>
        <ID>5</ID>
        <backgroundURL>/images/Backgroundw.png</backgroundURL>
        <hrefURL>#http://www.careersindustries.com/#</hrefURL>
        <imgURL>/images/p50a.png</imgURL>
        <company>Careers Industries</company>
      </Partners>
      <Partners>
        <ID>6</ID>
        <backgroundURL>/images/BackgroundY.png</backgroundURL>
        <hrefURL>#http://cityofracine.org/default.aspx#</hrefURL>
        <imgURL>/images/p23a.png</imgURL>
        <company>City of Racine</company>
      </Partners>
      <Partners>
        <ID>7</ID>
        <backgroundURL>/images/BackgroundY.png</backgroundURL>
        <hrefURL>#http://cnhind.com/en-US/Pages/HomePage.aspx#</hrefURL>
        <imgURL>/images/p04a.png</imgURL>
        <company>CNH</company>
      </Partners>
      <Partners>
        <ID>8</ID>
        <backgroundURL>/images/Backgroundw.png</backgroundURL>
        <hrefURL>#http://www.davidinsurance.com/#</hrefURL>
        <imgURL>/images/p34a.png</imgURL>
        <company>David Insurance</company>
      </Partners>
      <Partners>
        <ID>9</ID>
        <backgroundURL>/images/BackgroundY.png</backgroundURL>
        <hrefURL>#http://www.dentalassociates.com/#</hrefURL>
        <imgURL>/images/p35a.png</imgURL>
        <company>Dental Associates</company>
      </Partners>
    Code (markup):
    Here is the JQuery I have:
        $(document).ready(function(){
        $.get('/WellCityPartners.xml', function(xml){
           
                $(xml).find('Partners').each(function(){
                    var backgroundurl = $(this).find('backgroundURL').text();
                    var    hrefurl = $(this).find('hrefURL').text();
                    var    imgurl = $(this).find('imgURL').text();
                    var    td = "<td>";
                    var    tdc = "</td>";
                   
                    var html = '<tr><td><table style="width:234px" cellpadding="0" cellspacing="0"><tr >';
                    html += '<td style=" background-image:url(' + backgroundurl + '); height:100px; width:234px"';
                    html += 'align="center"><a href="' + hrefurl + '" target="_blank">';
                    html += '<img src="' + imgurl + '" /></a></td></tr></table></td>';   
                       
                    $('#partner').append($(html)); 
                    });
            });
        });
    
    Code (markup):
    Here is the HTML:
                  <table id="partner" cellpadding="0" cellspacing="0">
                    <tr>     
                 
              </tr>
            </table>
    Code (markup):

     
    Triel, Feb 3, 2014 IP
  2. Triel

    Triel Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #2
    Well thank you everyone but I have solved my problem so no need to respond.
     
    Triel, Feb 4, 2014 IP