Web Analytics Made Easy -
StatCounter Request values from jscript - CodingForum

Announcement

Collapse
No announcement yet.

Request values from jscript

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Request values from jscript

    Got some problem to request value from a js comboscript.

    There is no problem with the first value, but the second value will not show up on my preview-page.

    someone?


    <select name="region" size="1" onChange="redirect(this.options.selectedIndex)">
    <option>Alsace</option>
    <option>Aquitaine</option>
    <option>Auvergne</option>

    </select>
    <select name="depart" size="1">
    <option value="">Bas-Rhin -67</option>
    <option value="">Haut-Rhin -68</option>
    </select>&nbsp;

    <script>
    <!--

    /*
    Double Combo Script

    */

    var groups=document.FrontPage_Form1.region.options.length
    var group=new Array(groups)
    for (i=0; i<groups; i++)
    group[i]=new Array()

    group[0][0]=new Option("Bas-Rhin -67")
    group[0][1]=new Option("Haut-Rhin 68")

    group[1][0]=new Option("Dordogne - 24")
    group[1][1]=new Option("Gironde - 33")
    group[1][2]=new Option("Landes - 40")
    group[1][3]=new Option("Lot-et-Garonne -47")
    group[1][4]=new Option("Pyrénées-Atlantiques -64")

    group[2][0]=new Option("Allier -3")
    group[2][1]=new Option("Cantal -15")
    group[2][2]=new Option("Haute-Loire -43")
    group[2][3]=new Option("Puy-de-Dôme -63")


    var temp=document.FrontPage_Form1.depart

    function redirect(x){
    for (m=temp.options.length-1;m>0;m--)
    temp.options[m]=null
    for (i=0;i<group[x].length;i++){
    temp.options[i]=new Option(group[x][i].text,group[x][i].value)
    }
    temp.options[0].selected=true
    }

    function go(){
    location=temp.options[temp.selectedIndex].value
    }
    //-->
    </script>


  • #2
    Either specify the option value

    group[0][0]=new Option("Bas-Rhin -67", "Bas-Rhin -67 or any other value")
    group[0][1]=new Option("Haut-Rhin 68", "Haut-Rhin 68 or any other value")
    ...

    or remove the .value part in the redirect() function:

    for (i=0;i<group[x].length;i++){
    temp.options[ i ]=new Option(group[x][ i ].text) ; //group[x][ i ].value removed
    }
    Glenn
    vBulletin Mods That Rock!

    Comment

    Working...
    X