Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4249942
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:27:48+00:00 2026-05-21T04:27:48+00:00

How do I add code to the following to alternate the row color parsedata

  • 0

How do I add code to the following to alternate the row color

parsedata = function(xml){        
            var str = "";
            var cart = xml.documentElement.firstChild;
            if(cart.childNodes.length > 0 ){                
                str = str + '<table border="0" width="100%" cellspacing="0" cellpadding="5">';
                str = str + '  <tr><td class="animBoxCartLink" colspan="2"><a href="' + globals.cart_link + '">' + globals.cart_text + '</a></td></tr>
                for (var i = 0; i < cart.childNodes.length; i++){               
                    try{name =  cart.getElementsByTagName("NAME")[i].childNodes[0].nodeValue;}catch(e){name = "Item";}
                    try{attributes =  cart.getElementsByTagName("ATTRIBUTES")[i].childNodes[0].nodeValue;}catch(e){attributes = "";}
                    try{llink =  cart.getElementsByTagName("LINK")[i].childNodes[0].nodeValue;}catch(e){llink = "";}
                    try{image =  cart.getElementsByTagName("IMAGE")[i].childNodes[0].nodeValue;}catch(e){image = "No Image";}
                    try{qty =  cart.getElementsByTagName("QTY")[i].childNodes[0].nodeValue;}catch(e){qty = "message";}
                    try{price =  cart.getElementsByTagName("PRICE")[i].childNodes[0].nodeValue;}catch(e){price = "$0.00";}

                    dimension = (globals.cart_image_width ? 'width="' + globals.cart_image_width : '') + (globals.cart_image_height ? '" height="' + globals.cart_image_height + '"' : '');

                str = str + '  <tr>';
                str = str + '    <td class="animBoxCartImage" width="' + globals.cart_image_width + '" align="center"><a href="' + llink +'"><img src="' + image + '" ' + dimension + ' border="0" alt="' + name + '"></a></td>';
                str = str + '    <td class="animBoxCartContent" width="100%">';
                str = str + '      <div class="animBoxCartName"><a href="' + llink + '">' + name + '</a><br />' + attributes + '</div>';
                str = str + '      ' + globals.text_cart_quantity + ' ' + qty;
                str = str + '      <div class="animBoxCartPrice">' + price + '</a></div>';
                str = str + '      <a href="' + llink + '"> More Info </a>';
                str = str + '    </td>';
                str = str + '  </tr>';

The first half of the .js file (Jquery) pertains mostly to the show/hide of the cart which is located in the header and the portion I just posted is what I’m thinking is where I would need to add code where I can add styles so that the row color alternates.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T04:27:48+00:00Added an answer on May 21, 2026 at 4:27 am

    Keeping the rest of your code the same:

    Replace str = str + ' <tr>'; with:

    str = str + '  <tr class="rowcolor' + (i%2) + '">';
    

    Then you need css classes defined for the rowcolors:

    .rowcolor0 {
        background-color: #ffffff;
    }
    
    .rowcolor1 {
        background-color: #dddddd;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have an alternative table row color with the following javascript code: function
I just use following code to add an image to my project, var paper
The following code will add the categories selector widget to the WordPress Page editor
I have the following code to add authentication cookie to the response and redirect
I have the following Powershell code: Add-Type -Assembly System.Configuration [ExeConfigurationFileMap] $configMap = New-Object ExeConfigurationFileMap
I use the following code to add a Music player in my site, <div
I have the following Javascript code add_num = { f: function(html, num) { alert(this.page);
I am using following code for add button with image on tool bar, but
I am trying to add the following code work in a php file but
I'm using the following code to add separators between my menu items: #navigation_center li:before

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.