i am begineer to programming, i just try for the code what should i want and make copy and paste it and i will try to use it i just have a problem while using ajax i pasting the code so plz help me where i did my mistake,

please consider that i dont have any technical knowledge to understand the technical terms, plz help me

while i selected all the options then also i not getting the next dropdown box

my code is here
timetableupdate.php
PHP Code:

<head>

<script type="text/javascript">
function validate_form()
    {
          if(document.getElementById('reg').value=="")
            {
              alert("Please Select Regulation");
               return false; 
            }
            else
            if(document.getElementById('bcode').value=="")
            {
              alert("Please Select Branch");
               return false; 
            }else
            if(document.getElementById('year').value=="")
            {
              alert("Please Select Year");
               return false; 
            }else
            if(document.getElementById('sem').value=="")
            {
              alert("Please Select Semester");
               return false; 
            }
            //else
            //if(document.getElementById('sub_exp0').value=="")
            //{
            //  alert("Please Enter No of Times Taught");
            //   return false; 
            //}
            else
            {
             //return valid_sub();
            }    
    
    }

function showsub(str)
{
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
  else
  if(document.getElementById('reg').value=="")                                //Code For Validating The Form
         {
         alert("Please Select Regulation");
          return false;
         }
    else
    if(document.getElementById('reg').value=="")                                
         {
         alert("Please Select Regulation");
          return false;
         }     
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("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","getsemsubcode.php?sem="+str+ "&reg=" + reg + "&year=" + year + "&bcode=" + bcode,true);
xmlhttp.send();
}
</script>

<title>Time Table Updater</title></head>
<?php

include("..\dbdetails.php");
mysql_connect("$host""$dbusername""$dbpassword")or die("cannot connect server"); 
mysql_select_db("$dbname")or die("cannot select DB");

//Regulation display   $reg
echo "<select name=\"reg\">\n";
echo 
"<option value=\"\">Select Value</option>\n";
$sqla="SELECT * FROM $tbl_name group BY `Regulation` ASC ";
$resulta=mysql_query($sqla);
while(
$rowa mysql_fetch_assoc($resulta))
{
$reg=$rowa['Regulation'];
echo 
"<option value=\"$reg\">$reg</option>";

echo 
"</select>";


//Branch display   $bcode
echo "<select name=\"bcode\">\n";
echo 
"<option value=\"\">Select Value</option>\n";
$sqlc="SELECT * FROM $tbl_name group BY `Branch` ASC ";
$resultc=mysql_query($sqlc);
while(
$rowc mysql_fetch_assoc($resultc))
{
$bcode=$rowc['Branch'];

if(
$bcode==0)  {$bname="MCA";}
elseif(
$bcode==1)  {$bname="CIVIL";}
elseif(
$bcode==2)  {$bname="EEE";}
elseif(
$bcode==4)  {$bname="ECE";}
elseif(
$bcode==5)  {$bname="CSE";}
elseif(
$bcode==12)  {$bname="IT";}

echo 
"<option value=\"$bcode\">$bname</option>";

echo 
"</select>";

//Year display  $year
echo "<select name=\"yr\">\n";
echo 
"<option value=\"\">Select Value</option>\n";
$sqld="SELECT * FROM $tbl_name group BY `Year` ASC ";
$resultd=mysql_query($sqld);
while(
$rowd mysql_fetch_assoc($resultd))
{
$year=$rowd['Year'];
echo 
"<option value=\"$year\">$year</option>";

echo 
"</select>";

//Sem display   $sem
echo "<select name=\"sem\" onchange=\"showsub(this.value)\">\n";
echo 
"<option value=\"\">Select Value</option>\n";
$sqle="SELECT * FROM $tbl_name group BY `Sem` ASC ";
$resulte=mysql_query($sqle);
while(
$rowe mysql_fetch_assoc($resulte))
{
$sem=$rowe['Sem'];
echo 
"<option value=\"$sem\">$sem</option>";

echo 
"</select>";

//echo "<select name=\"level\" onchange=\"showsub(this.value)\">\n";

mysql_close();
?>

getsemsubcode.php

PHP Code:
<?php

$reg
=$_GET["reg"];
$year=$_GET["year"];
$bcode=$_GET["bcode"];
$sem=$_GET["sem"];

include(
"..\dbdetails.php");
mysql_connect("$host""$dbusername""$dbpassword")or die("cannot connect server"); 
mysql_select_db("$dbname")or die("cannot select DB");


echo 
"<select name=\"reg\">\n";
echo 
"<option value=\"\">Select Value</option>\n";

$sql="SELECT * FROM user WHERE `Regulation` = '".$reg."' AND `Branch` = '".$bcode."' AND `Year` = '".$year."' AND
         `Sem` = '"
.$sem."'   ";


$result=mysql_query($sql);
while(
$row mysql_fetch_assoc($result))
{

$scode=$row['Subcode'];
$sname=$row['Subname'];

$sdisp="$scode"+ - +"$sname";

echo 
"<option value=\"$scode\">$sdisp</option>";

echo 
"</select>";


mysql_close();
?>
mysql table structure
Code:
Field 	Type 	Null 	Default 	
Htno 	varchar(10) 	Yes  	NULL  	  	 
Regulation 	varchar(3) 	Yes  	NULL  	  	 
level 	varchar(2) 	No  	  	  	 
Branch 	int(2) 	Yes  	NULL  	  	 
Year 	int(1) 	Yes  	NULL  	  	 
Sem 	int(1) 	Yes  	NULL  	  	 
Subcode 	varchar(5) 	Yes  	NULL  	  	 
Subname 	varchar(44) 	Yes  	NULL  	  	 
DOESERIAL 	int(2) 	No  	  	  	 
session 	varchar(2) 	No
plz help me, i really need help for this