So ultimately my goal is this: I have a table of info (from mySQL database) being displayed on my page, btracker.php. On this page is a pulldown menu for the month and the year (I need both to work but for now I'm just trying to solve the month).

<form name="pageFilter" action="bTracker-test.php" method="post">
                	<select name="selectmonth" onChange="sortMonth(this.value, '0')">
                        <option selected="selected" value="0">--Select Month--</option>
                        <option value="1">January</option>
                        <option value="2">Feburary</option>
                        <option value="3">March</option>
                        <option value="4">April</option>
                        <option value="5">May</option>
                        <option value="6">June</option>
                        <option value="7">July</option>
                        <option value="8">August</option>
                        <option value="9">September</option>
                        <option value="10">October</option>
                        <option value="11">November</option>
                        <option value="12">December</option>
                    </select>

The page loads with

$m = date("m")

but then onChange I expect the $m value to change to the option value selected and then reload or redisplay. Currently I've gone about this a couple ways and I'm trying to simplify it because the way I started to go seemed to difficult for something like this.

My simple onChange javascript function looks like this so far:

function sortMonth() {
    var list = document.forms['pageFilter'].selectMonth
        if(list.selectedIndex != 0) {
            document.m=list.options[list.selectedIndex].value;
			document.location.reload(true);
    }
}

* So far this does nothing so it may not even be on the right track

My complex onChange javascript function looks like this so far (friend helped me figure this out so don't fully understand it yet):

function sortdata(sortmonth, sortyear)
{
var xmlhttp;  
if (sortmonth=="0")
  {
  document.getElementById("btrackerdata").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("btrackerdata").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","btrackersort.php?m="+sortmonth+"&y="+sortyear,true);
xmlhttp.send();
}

*At the moment this works but for some reason when it pulls February it displays march (with February's results from DB, just formatted as march). Plus this seems complex already for something I thought would be fairly simple and it still doesn't work with the year yet.

If I'm on the right track with one of these let me know which one is better and what I need to do to get the results I'm looking for. Also any thoughts about fixing the year would be helpful too but most importantly is getting the months to work right now. Thanks so much, you guys have made this place the best forum to be a part of.

So I haven't heard anything back and since option #1 is not producing ANY results I'm going to work with option #2, but in that case I need to find out where the issue is that because even when $m = 2 (which should make the month title February) the title still displays as March. Also with this option I need to find out how to get the year filter to work. Thanks so much for your help whoever is out there to help me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.