Jquery - Load an XML file based on drop-down menu selection
<p>I am a noob who is trying to create a q&amp;a application. At the moment, I have been experimenting with the apparent simplicity of Jquery. I need a Jquery or Javascript function that (1) allows the user to select a Q&amp;A category from a drop-down box and (2) tells the Jquery code which XML file to select based on the user's selection. What is done with the XML file after it is selected is another matter.</p>

<p>I was successful in creating a function with a pre-defined XML file variable - </p>

<pre><code>$("#target").click(function() { 
    var a = 'TestFile2.xml';
    var b = 'TestFile3.xml';
    var c = 'TestFile4.xml';
    $.ajax({
        url: c,
        type: 'GET', 
        dataType: 'xml',
        success: parseXML
    });
})
</code></pre>

<p>But I have been unsuccessful in creating a function that connects the XML file to be used to a drop-down menu. This is the Javascript function I have been trying to make work - </p>

<pre><code>&lt;div id="target"&gt;
  Click here
&lt;/div&gt;

&lt;script type="text/javascript"&gt;

function (selFile() 
{

var p = document.LoadCategory.Load.value;

    if (p == "testFile2") {var x = "TestFile2.xml"}     

    if (p == "testFile3") {var x = "TestFile3.xml"}         

    if (p == "testFile4") {var x = "TestFile4.xml"} 

})

$("#target").click(function()

{ 

 $.ajax({

            url: x,

            type: 'GET', 

            dataType: 'xml',

            success: parseXML

       });
})
</code></pre>

<p>I have tried many variations on the above but to no avail. I have a feeling that I am doing something really simple really wrong. I'd be really grateful for any tips or suggestions.</p>
