drop down menu not passing the value AJAX, PHP, SQL

I have 3 drop down boxes that populate themselves however the 3rd box will not pass the modelID through the URL on the onChange. I know it has got to be something small. I just need the this.value to actually translate to modelID.

I set the initial value to tell me if it is passing the values through so I know that year is passing through to the third box just not the make. It keeps telling me that that value is = 0

Any ideas would be greatly appreciated!
//My function looks like

function getModel(yearID,makeID) {		
		var strURL="findModelA.php?YEAR="+yearID+"&MAKE="+makeID;

		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('modelDIV').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					} //if(req.status
				}	// if(req.ready			
			}	// req.onready		
			req.open("GET", strURL, true);
			req.send(null);
		} //if req
				
	} //function


// My php looks like

<?php 

$year=intval($_GET['YEAR']);

require_once('includes/connection.php'); 

$query="SELECT DISTINCT make FROM pages WHERE year='$year'";
$result=mysql_query($query);

?>

<select name="make" id="make" onChange="getModel(<?php echo $year; ?>,this.value)" style="width:230px;margin-top:-10px;">
<option><? echo "y is ".$year;?></option>
<? while($row=mysql_fetch_array($result)) { ?>
<option value=<?=$row['make']?>> <?=$row['make']?> </option>
<? } ?>
</select>

Open in new window

Jen765Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

carsRSTCommented:
Try these particular changes....



function getModel(yearID) {            
      var makeID;
      makeID = document.getElementById("make").value
      var strURL="findModelA.php?YEAR="+yearID+"&MAKE="+makeID;
...rest of code....



<select name="make" id="make" onChange="getModel(<?php echo $year; ?>)" style="width:230px;margin-top:-10px;">
Jen765Author Commented:
It still is telling me that the value is equal to 0. The thing is even when I change the function to be just the makeID only ex: getModel(makeID) and use "this.value" it still is pulling up as 0. So maybe it is the way I am passing the variable?
Jen765Author Commented:
I don't understand why it isn't sending properly. I tested the value by doing an onChange="alert(this.value)" and it comes up with the proper value. For some reason it just isn't sending back to the javascript what the value is. I changed it to say...

function getModel(yearID) {      
            
            var makeID = document.myform.thisMake.options[document.myform.thisMake.selectedIndex].value;
            var strURL="findModelA.php?YEAR="+yearID+"MAKE="+makeID;      
            var req = getXMLHTTP();

still is only coming up with the correct year but the make value it says is 0.

Any more ideas???
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

carsRSTCommented:
Without being able to see the values in your dropdown, nothing really looks out of line.

One thing you may add is a ";" after your getModel function in the onchange event.
carsRSTCommented:
Can you post your HTML view source?
Jen765Author Commented:
I was able to find the problem. The problem wasn't in my function it was in my php code the line that said:

$year=intval($_GET['YEAR']);

the value of the make and model wasn't an integer so that's where my problem was. All i needed to do was change it to a regular $_GET[] and the problem was solved.

I knew it had to be something small.

Thank you so much for your help!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.