I have a bit of code and basically I cant get it to work.

The idea is a country, region thing which has been many times, but for some reason, when I choose the country the region drop down acknowledges the selction has been made but only 'Anywhere' rather than the value, and no values appear.

Then when I come into the page having already selected a hotel, the country works well, the correct region values for the country show up, but it stays on the first one, rather than jumping to the correct value.

Hopefully someone can spot the problem, and help me out.

Code:
var country = new Array();
var region = new Array();
var countryregion = new Array();
function fillregion(countryid)
{
   
var i=0;
document.form1.selregion.options.length=0;
for(j=0;j<=countryregion.length;j++)
{   
if(countryregion[j]==countryid)
{
/*document.form1.selregion.options[i] = new Option()*/
document.form1.selregion.options[i] = new Option(region[j],j)
document.form1.selregion.options[i].value=j;
document.form1.selregion.options[i].innerText=region[j];
i++;
}
}
 
if(countryid==0 || i==0 )
{
document.form1.selregion.options[0] = new Option()
document.form1.selregion.options[0].value=0;
document.form1.selregion.options[0].innerText="Anywhere";
}
}


     <select name="selcountry" size="1" onChange="fillregion(this.value);">
     <?php $qw=mysql_query("select * from tbl_countries order by Nom_Cntry") or die (mysql_error());
     while($r=mysql_fetch_assoc($qw))
     { 
      if($r['Id_Cntry']==$hotcntry)
      {
       echo "<option value='$r[Id_Cntry]' selected>$r[Nom_Cntry]</option>";
      }
      else
      {
       echo "<option value='$r[Id_Cntry]'>$r[Nom_Cntry]</option>";
      }
       } ?>
     </select>

<select name="selregion" size="1">
     <?
      $qu=mysql_query("select * from tbl_resorts where IdCntry_Rsrt=$hotcntry"); // or die (mysql_error());
      while($r=mysql_fetch_assoc($qu))
      {      
       if($r['Id_Rsrt']==$regioncmb)
       {
       echo "<option name=$r[1] selected>$r[Nom_Rsrt]</option>";
       }
       else
       {
       echo "<option name=$r[1]>$r[Nom_Rsrt]</option>";       
       }
      }
      
      
     ?>
       </select>