www.webdeveloper.com
Results 1 to 2 of 2

Thread: Link in Select List

  1. #1
    Join Date
    Nov 2012
    Posts
    1

    Post Link in Select List

    Hi, i want to put a link in the last option of this select list(the array element, like Cádiz, Córdoba,etc), depending of the option the link must be diferent, the problem is i have no idea how to do that i'm a noob in javascript topic.

    Here´s an example of my list:

    Javascript:

    Code:
    <script languaje="JavaScript">
    <!-- 
    provincias = new Array();
    provincias[0] = new Array();
    provincias[1] = new Array('Almería','Cádiz','Córdoba','Granada','Huelva','Jaén','Málaga','Sevilla');
    provincias[2] = new Array('Huesca','Teruel','Zaragoza');
    provincias[3] = new Array('Asturias');
    provincias[4] = new Array('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;
      while(vector[i]){
        select2.options[i].value = vector[i];
        select2.options[i].text = vector[i];
        i++;
      }
      select2.options[0].selected = 1;
    }
    -->
    </script>
    HTML:

    Code:
    <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">
      <option>-</option>
      </select></p>
    </form>
    Thank you

    PD: sorry for my bad english

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,351

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles