View Single Post
Old 11-20-2012, 07:30 PM   PM User | #9
linkysnake
New Coder

 
Join Date: Nov 2012
Posts: 11
Thanks: 7
Thanked 0 Times in 0 Posts
linkysnake is an unknown quantity at this point
Ok, the problem is i don't have idea of where to place the minor changes in the post #4 ,that's why i'm asking you for the complete example code ..... i'm using this one:

Code:
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8" />
<title> Untitled </title>

<script type="text/javascript">
provincias = new Array();
provincias[0] = [];
provincias[1] = ['-|-','Almería|-','Cádiz|-','Córdoba|-','Granada|-','Huelva|-','Jaén|-','Málaga|-','Sevilla|-'];
provincias[2] = ['-|-','Huesca|http://www.webdeveloper.com','Teruel|http://www.codingforums.com','Zaragoza|http://www.dreamincode.net'];
provincias[3] = ['-|-','Asturias|-'];
provincias[4] = ['-|-','Baleares|-'];

function cambiar(formulario){
  var i = 0;
  var select1 = formulario['D1'];
  var select2 = formulario['D2'];
  var vector = provincias[select1.selectedIndex];
  if(vector.length)select2.length=vector.length;
  var tarr = [];
  while(vector[i]){
    tarr = vector[i].split('|');
    select2.options[i].value = tarr[1];
    select2.options[i].text = tarr[0];
    i++;
  }
  select2.options[0].selected = 1;
}
function linkToSite(info) {
  if (info != '-') { alert(info); }  // this line is for testing purposes only
  if (info != '-') { document.location.href = info; }
}

function linkToSite(formulario) {
  var select1 = formulario['D1'];
  var select2 = formulario['D2'];
  alert('baseURL '+select1.value+' '+select2.value);
}
</script>

<style type="text/css">

</style>
</head>
<body>
<form method="POST">
  <select name="D1" onchange="cambiar(this.form)">
  <option>-</option>
  <option>Andalucía</option>
  <option>Aragón</option>
  <option>Asturias</option>
  <option>Baleares</option>
  </select>
  <select name="D2" onchange="linkToSite(this.value)">
  </select></p>
</form>
</body>
</html>
thank you again
linkysnake is offline   Reply With Quote