Click here to Skip to main content
15,442,578 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
0


Totally new to this.

I have got the following dropdown code working with no dramas, but I have been stuck/searching to add another column (to be hidden) to use as a reference for a table lookup with the reference (Hidden textbox) being for a filter, selected after you have chosen the correct student, for a table (I will try build) under the dropdown from which I will fill from another XML file. (The common column in both XML files will be the 'STUID' column.

The Dropdown XML is a file with DISTINCT NAMES and STUID (2 columns in total) of all students. The Table XML has STUID and other information. (8 columns in total)

If someone can point me in the right direction it would be much appreciated. As mentioned above, I am totally new to this and just finding snippets here and there for what I need to do on this small project.

Here is my current Code:
    <pre><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" type="text/css" media="all" href="style.css" />
    <script type="text/javascript" src="jquery.min.js"></script>
    <title>Using jQuery and XML to populate a drop-down box demo</title>
    
    <script>
    $(document).ready(function(){
    $.ajax({
    type: "GET",
    url: "PDC_InstrExport2.xml",
    dataType: "xml",
    success: function(xml) {
    var select = $('#mySelect');
    
    $(xml).find('tbl_PDC_InstrWEB_Export2').each(function(){
    $(this).find('Name').each(function(){
    
    //$('Name', xml).each(function(){
    var value1 = $(this).text();
    
    select.append("<option class='ddindent' value='"+ value1 +"'>"+value1+"</option>");
    
    });
    });
    select.children(":first").text("Select PDC Student").attr("selected",true);
    } //sucess close
    }); 
    }); 
    </script>
    </head>
    <body>
    <input name="Hidden1" type="hidden" />
    
    
    <h2>Header is Here</h2>
    <img src="Monkey.jpg" alt="Logo Here" width="80" height="80"/>
    
    <div id="page-wrap">
    <select id="mySelect">
    <option>loading</option>
    </select>
    </div>
    </body>
    </html>





Sample of the Dropdown XML file is as follows:

-

-<tbl_pdc_instrweb_export2>ABELLANOSA, ELAINE JOY-4W

21-05C-158

-<tbl_pdc_instrweb_export2>ALBA, RUBY SOCORRO-4W

21-05C-411

-<tbl_pdc_instrweb_export2>AMODIA, FAY LORRAINE-2W

20-05E-1813

-<tbl_pdc_instrweb_export2>AWE, DEONA MAE-4W

21-05C-430



What I have tried:

Inserting another line after $(this).find('Name').each(function(){ with new 'find' as such $(this).find('StuID').each(function(){

I am totally lost
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900