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 9259567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:41:17+00:00 2026-06-18T12:41:17+00:00

I hope that someone will know how to help me with this problem, I

  • 0

I hope that someone will know how to help me with this problem, I am new to javaScript and XML. Basically I have the xml file with list of products, I have managed to dynamically load the data into an ul li list in my html page, the li elements has title and image, and now I need to be able to click on this li element and load remaining data for a specific product into a new page (or div). I am getting the “Uncaught ReferenceError: i is not defined” My question is how could I load the correct remaining data after clicking on a specific product from the list of products. (I hope that my explanation is clear enough) here is my code, the first function produces the ul li list in the html page, the displayPRInfo() function should load the data into showPrInfo div for any product which was clicked.

please help me, any help appreciated , thanks for reading.

function loadProducts() {
var liOpen=("<li onclick='displayPRInfo(" + i + ")'><p>");
      var divOpen=("</p><div class='prod-sq-img'>");  
      var closingTags=("</div></li>");
    var txt;
    var image;
    var title;


    var x=xmlDoc.getElementsByTagName("product");
    for (i=0;i<x.length;i++)
      { 
      title=(x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue);
      image=(x[i].getElementsByTagName("imgfile")[0].childNodes[0].nodeValue);
      txt=  liOpen +  title + divOpen + image + closingTags ;
      document.getElementById("ulList").innerHTML+=txt;
      }

    }
        function displayPRInfo(i)
{
title=(x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue);
euPriceRet=(x[i].getElementsByTagName("euror")[0].childNodes[0].nodeValue);
euPriceTrade=(x[i].getElementsByTagName("eurot")[0].childNodes[0].nodeValue);
euPriceSet=(x[i].getElementsByTagName("eset")[0].childNodes[0].nodeValue);
minimumQuantity=(x[i].getElementsByTagName("mqty")[0].childNodes[0].nodeValue);
description=(x[i].getElementsByTagName("desc")[0].childNodes[0].nodeValue);
prBigImg=(x[i].getElementsByTagName("pimgfile")[0].childNodes[0].nodeValue);
prInfo=title+"<br>"+euPriceRet+"<br>"+euPriceTrade+"<br> "+euPriceSet+"<br> "+minimumQuantity+"<br>"+description+"<br>"+ prBigImg ;
document.getElementById("showPrInfo").innerHTML=prInfo;
}
  • 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-06-18T12:41:18+00:00Added an answer on June 18, 2026 at 12:41 pm

    You can use jQuery to manipulate xml and set onclick events.

    function loadProducts() {
        var products = $(xmlDoc).find('product');
    
        for (var i = 0; i < products.length; i++) {
          $('#ulList').append('<li id="product_' + i + '"><p>' + $(products[i]).find('title').text() + '</p><div class="prod-sq-img">' + $(products[i]).find('imgfile').text() + '</div></li>');
          $('#product_' + i).click(displayPRInfo.bind($('#product_' + i), products[i]));
        }
     }
    
    function displayPRInfo(xmlProduct) {
      var title= $(xmlProduct).find('title).text();
      var euPriceRet = $(xmlProduct).find('euror').text();
      var euPriceTrade = $(xmlProduct).find('eurot').text();
      var euPriceSet = $(xmlProduct).find('eset').text();
      var minimumQuantity = $(xmlProduct).find('mqty').text();
      var description = $(xmlProduct).find('desc').text();
      var prBigImg = $(xmlProduct).find('pimgfile').text();
      var prInfo = title+"<br>"+euPriceRet+"<br>"+euPriceTrade+"<br> "+euPriceSet+"<br> "+minimumQuantity+"<br>"+description+"<br>"+ prBigImg ;
      $('#showPrInfo').html(prInfo);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I really hope someone can help with this problem. I have an ajax pagination
I'm throwing this out there in hope that someone will have attempted something this
I bumped into the following problem, hope someone will know how to help me:
Happy New Year SO users! I have an issue that I hope someone can
I hope someone here can help me. I know that in IE 9, there
I'm new to CakePHP and hope someone could help me with this one. I
I'm having some javascript conflict problem, and hope someone can help me out. I'm
I am having a JQuery/ASP issue that I hope someone can help me with.
I hope you will help me understand this Copy Constructor I took more then
I hope someone can help me with this one. I want to take an

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.