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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:40:43+00:00 2026-06-14T22:40:43+00:00

BIG EDIT 11/19/2012 So, my problem is here. I’m trying to develop a simple

  • 0

BIG EDIT 11/19/2012

So, my problem is here.
I’m trying to develop a simple cart app with jQuery and XML.

Everything’s OK, but only if the name of My pizz only contains numbers… WHY ???

Try yourself, you’ll constat that only the “66666” pizza is working… WHY ???

WORKING DEMO HERE

Here is my jS code:

$(document).ready(function(){
 $.ajax({
  type: "GET",
  url: "example.xml", 
  dataType: ($.browser.msie) ? "text" : "xml",
  success: function(xml) {  
   $(xml).find('row').each(function(){
    var Col0 = $(this).find('nompizz').text();
    var Col1 = $(this).find('petit').text();
    var Col2 = $(this).find('moyen').text();
    var Col3 = $(this).find('grand').text();

    $('<tr id="bar"></tr>').html('<th class="title">'+Col0+'</th><td onclick="DisPlay('+Col1+');GetName('+Col0+');">'+Col1+'€</td><td onclick="DisPlay('+Col2+');GetName('+Col0+');">'+Col2+'€</td><td onclick="DisPlay('+Col3+');GetName('+Col0+');">'+Col3+'€</td>').appendTo('#pizzas');

   });
  }
 }); 
});
function DisPlay(Figure) {   
     var Display = document.getElementById('Display');
     if (Figure === null) {
         Display.value = Figure;
     }
     else {
         Display.value += "+"+Figure;
         Screen = Display.value
         result = eval(Screen);

         Display.value =result;
     }

      Figure = null;
}
function GetName(NomPizz) {
      var $newItem = '<li>Ajouté: '+NomPizz+'</li>';
      $('.theList').append($newItem); 
}

And here my XML:

<?xml version="1.0"?>
<document>
 <row>
  <nompizz>66666</nompizz>
  <petit>10</petit >
  <moyen>15</moyen >
  <grand>20</grand>
 </row>
 <row>
  <nompizz>Letters</nompizz >
  <petit>15</petit >
  <moyen>20</moyen >
  <grand>25</grand>
 </row>
</document>
  • 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-14T22:40:44+00:00Added an answer on June 14, 2026 at 10:40 pm

    I think your problem is that your GetAnswer() function is agnostic to the rest of the application. It doesn’t know what was clicked. I think that the easiest thing to do would be to just add the nom parameter to your DisPlay() function call. Like this: (remove the linefeeds)

    $('<tr id="bar"></tr>').html('<th class='+Col0+' data-item='+Col0+'>'+Col0+'</th>    <td onclick="DisPlay('+Col1+',\"'+Col0+'\")">'+Col1+'€</td>    <td onclick="DisPlay('+Col2+',\"'+Col0+'\")">'+Col2+'€</td>    <td onclick="DisPlay('+Col3+',\"'+Col0+'\")">'+Col3+'€</td>').appendTo('#pizzas');
    

    Then your DisPlay(Figure) becomes:

    function DisPlay(Figure, nom) {
        var Display = document.getElementById('Display');
        if (Figure === null) {
            Display.value = Figure;
        }
        else 
        {
            Display.value += "+"+Figure;
    
            //instead of this --> //GetAnswer();
    
            //in your old code you had some of these variables declared as non-global variables, but were using them like they were global variables
            Screen = Display.value.replace(/'/g, ' ');
            result = eval(Screen);   
            Display.value = result;
            $('.theList').append('<li>Ajouté: '+nom+'</li>');
        }
        Figure = null;
    }
    

    A word about global variables vs. non-global variables. If you ‘var’ something inside a function, that variable is local to that function. It seems like you were mixing and matching your vars. For more on that read this post.

    EDIT:

    After your new edits you are only getting numeric pizza names because you need to have quotes int he proper place. Try changing all your GetName('+Col0+'); to GetName(\''+Col0+'\');

    So that whole line would read:

    $('<tr id="bar"></tr>').html('<th class="title">'+Col0+'</th><td onclick="DisPlay('+Col1+');GetName(\''+Col0+'\');">'+Col1+'€</td><td onclick="DisPlay('+Col2+');GetName(\''+Col0+'\');">'+Col2+'€</td><td onclick="DisPlay('+Col3+');GetName(\''+Col0+'\');">'+Col3+'€</td>').appendTo('#pizzas');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom edit form made for ASPxGridView but have a big problem
I have a relatively big SSIS package which I'm trying to edit. I basically
I am using SVG-Edit to create a pretty big SVG image file. The problem
hello I have a big problem with a button on click and two edit
Big problem. I'm not sure what it was that I did, but it seems
IMPORTANT EDIT: Sorry everyone, i made a big mistake in the structure. char *name;
And have a big blob of values, with a space in between? Edit: What
Im having a big headcache with a header design: Here the demo: http://jsfiddle.net/uGECm/ The
(Big edit, I got part of the way there…) I've been hacking away and
I am doing string matching with big amount of data. EDIT: I am matching

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.