Alrighty, my page has two sets of radio buttons. I want the user to click one from one set, then another from another set, resulting in a list of items that are shared between the two sets. I can get each set to work separately, but they're not cooperating together. Wow, that sounds confusing. Here's some of the code:
//Set 1 (radio button 1 displays an array of items a, b, c; rb2 displays d, e, f):
...onClick="ajaxHandler2(this.value)"...
//Set 2(rb3 displays a, b, d, f; rb4 does b, c, d, e)
...onClick="ajaxHandler2(this.value)"...
So, for example, if the user selects rb1 and rb3, what I want displayed in my div is :
a
b
//the important part of my ajax handlers. This is where I think I'm messing up. Never used ajax before...
function ajaxHandler(arg)
{
xhr = new XMLHttpRequest();
xhr.onreadystatechange = readyStateHandler;
xhr.open("GET", "myServlet?firstChoice" + "=" + arg, true);
xhr.send(null);
}
function ajaxHandler2(arg)
{
xhr = new XMLHttpRequest();
xhr.onreadystatechange = readyStateHandler;
xhr.open("GET", "myServlet?secondChoice" + "=" + arg, true);
xhr.send(null);
}
function readyStateHandler()
{
if (xhr.readyState==4)
{
document.getElementById("placeholder").innerHTML = xhr.responseText;
}
}
//part of my servlet, where I could also be messing up
for(int k=0; k<firstArray.length; k++)
{
for(int m=0; m<secondArray.length; m++)
{
if(firstArray[k].equals(secondArray[m]))
{
out.println(firstArray[k]);
out.println("<br/>");
}
}
}