facebook

Creating and Calling Variables in Custom.js file

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #341884 Reply

    dannyg280
    Member

    Newbie question, but I am pulling some data from an XML file. I am using the example from the LoadXMLFileDemo. In the code below, which is in my custom.js file, it pulls the product name from an XML file based on the product ID. It works fine when I specify the id. But now I want the ID to come from the value of a combobox. The variable “pval” below is my attempt to pull that value. I either am not pulling the value correctly, or I am not calling the variable correctly for my id. Can you tell me what I’m doing wrong?

    
    function loadXMLFile(url){
      phoneui.showActivityDialog("loading");
      $.get(url, function(xmlDoc){
        phoneui.hideActivityDialog();
        var pval= $('select[name="pname"]').val();
        var newpname = $(xmlDoc).find('product[id=pval] pname').text();
        updateTextArea(newpname);    
      },"xml");
    }
    
    
    #341895

    support-michael
    Keymaster
    
    //your code searches for <product id="pval"><pname>
    var newpname = $(xmlDoc).find('product[id=pval] pname').text();
    
    //in this snippet the value of pval is inserted into the query
    var newpname = $(xmlDoc).find('product[id=' + pval + '] pname').text();
Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Creating and Calling Variables in Custom.js file

You must be logged in to post in the forum log in