I know this question had been asked before but I am not a coder (trying to learn), so I could not find any examples or answers that looked like my website's coding through previous questions.
The problem: My form should populate makes of cars, then it will automatically populates models. (the models works fine when the makes have been populated).
But I have to click twice on the intial makes part of the form for the data to populate.
The top part of my form code:
<td><b>Make:</b><br /> <span id="makesList"><select onclick="getMakes(<?php echo SITETYPE2 ?>)" onchange="getModels(this.value, <?php echo SITETYPE2 ?>)" class="required" id="makeid" name="makeid" >
Javascript/Ajax function
function getMakes(str)
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="/getmakes.php";
url=url+"?typeid="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChangedMakes;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
Can you help me? Remember I am not a coder, just trying to learn what someone else has coded.
Thanks Mark
The best thing to do with dropdowns (select) is to use onchange. As you have the onchange event already firing i would use mouseup as that happens before the click event. Also there may just be a delay between the client and your web server. Try clicking initially then click off the screen to see if the next lot of results appear.
Also your php echo statements have no semicolon at the end. This should give an error