Web Analytics Made Easy -
StatCounter need help with this script - CodingForum


No announcement yet.

need help with this script

  • Filter
  • Time
  • Show
Clear All
new posts

  • need help with this script

    I need help with the attached script. It´s a double combo script with redirect. The thing is that i dont need the redirect part of this script. I´m not a pro on javascript so i need some help on what parts to remove.

    <form name="doublecombo">
    <p><select name="example" size="1" onChange="redirect(this.options.selectedIndex)">
    <option>Pays de la Loire</option>
    <option>Provance-Alpes-Côte d´Azur</option>
    <select name="stage2" size="1">
    <option value="">Bas-Rhin</option>
    <option value="">Haut-Rhin</option>


    Double Combo Script Credit
    By JavaScript Kit (www.javascriptkit.com)
    Over 200+ free JavaScripts here!

    var groups=document.doublecombo.example.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")

    group[3][0]=new Option("Calvados -14")
    group[3][1]=new Option("Manche -50")
    group[3][2]=new Option("Orne -61")

    group[4][0]=new Option("Côte-d'Or -21")
    group[4][1]=new Option("Nièvre -58")
    group[4][2]=new Option("Saône-et-Loire -71")
    group[4][3]=new Option("Yonne -89")

    group[5][0]=new Option("Côtes-d'Armor -22")
    group[5][1]=new Option("Finistère -29")
    group[5][2]=new Option("Ille-et-Vilaine -35")
    group[5][3]=new Option("Morbihan -56")

    group[6][0]=new Option("Cher -18")
    group[6][1]=new Option("Eure-et-Loir -28")
    group[6][2]=new Option("Indre -36")
    group[6][3]=new Option("Indre-et-Loir -37")
    group[6][4]=new Option("Loir-et-Cher -41")
    group[6][5]=new Option("Loiret -45")

    group[7][0]=new Option("Ardennes -8")
    group[7][1]=new Option("Aube -10")
    group[7][2]=new Option("haute-Marne -52")
    group[7][3]=new Option("Marne -51")

    group[8][0]=new Option("Doubs -25")
    group[8][1]=new Option("Haute-Saône -70")
    group[8][2]=new Option("Jura -39")
    group[8][3]=new Option("Territoire-de-Belfort -90")

    group[9][0]=new Option("Eure -27")
    group[9][1]=new Option("Seine-Maritime -76")

    group[10][0]=new Option("Essonne -91")
    group[10][1]=new Option("Haute-de-Seine -92")
    group[10][2]=new Option("Paris-75")
    group[10][3]=new Option("Seine-Saint-Denis -93")
    group[10][4]=new Option("Seine-et-Marne -77")
    group[10][5]=new Option("Val-d'Oise -95")
    group[10][6]=new Option("Val-de-Marne -94")
    group[10][7]=new Option("Yvelines -78")

    group[11][0]=new Option("Corse-du-Sud 2A")
    group[11][1]=new Option("Haute-Corse -2B")

    group[12][0]=new Option("Aude -11")
    group[12][1]=new Option("Gard -30")
    group[12][2]=new Option("Hérault -34")
    group[12][3]=new Option("Lozère -48")
    group[12][4]=new Option("Pyrénées-Orientales -66")

    group[13][0]=new Option("Corrèze -19")
    group[13][1]=new Option("Creuse -23")
    group[13][2]=new Option("Haute-Vienne -87")

    group[14][0]=new Option("Meurthe-et-moselle -54")
    group[14][1]=new Option("Meuse -55")
    group[14][2]=new Option("Moselle -57")
    group[14][3]=new Option("Vosges -88")

    group[15][0]=new Option("Ariège -9")
    group[15][1]=new Option("Aveyron -12")
    group[15][2]=new Option("Gers -32")
    group[15][3]=new Option("Haute-Garonne-31")
    group[15][4]=new Option("Haute-Pyrénées -65")
    group[15][5]=new Option("Lot -46")
    group[15][6]=new Option("Tarn -81")
    group[15][7]=new Option("Tarn-et-Garonne -82")

    group[16][0]=new Option("Nord -59")
    group[16][1]=new Option("Pas-de-Calais -62")

    group[17][0]=new Option("Loire-Atlantique -44")
    group[17][1]=new Option("Maine-et-Loire -49")
    group[17][2]=new Option("Maynne -53")
    group[17][3]=new Option("Sarthe -72")
    group[17][4]=new Option("Venndèe -85")

    group[18][0]=new Option("Aisne -2")
    group[18][1]=new Option("Oise -60")
    group[18][2]=new Option("Somme -80")

    group[19][0]=new Option("Charente -16")
    group[19][1]=new Option("Charente-Maritime -17")
    group[19][2]=new Option("Deux-Sèvres -79")
    group[19][3]=new Option("Vienne -86")

    group[20][0]=new Option("Alpes-Maritimes -6")
    group[20][1]=new Option("Aples-de-Haute-Provance -4")
    group[20][2]=new Option("Bouches-de-Rhône -13")
    group[20][3]=new Option("Haute-Alpes -5")
    group[20][4]=new Option("Vaucluse -84")

    group[21][0]=new Option("Ain -1")
    group[21][1]=new Option("Ardèche -7")
    group[21][2]=new Option("Drôme -26")
    group[21][3]=new Option("Haute-Savoie -74")
    group[21][4]=new Option("Isère -38")
    group[21][5]=new Option("Loire -42")
    group[21][6]=new Option("Rhône -69")
    group[21][7]=new Option("Savoie-73")

    var temp=document.doublecombo.stage2

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

    function go(){


    Some hint.. ??
    Attached Files
    Last edited by Mr Barcode; Feb 27, 2004, 01:31 PM.

  • #2
    I dont quite understand your goal, but to stop the redirect function, remove the onChange handler and the redirect function

    <select name="example" size="1" onChange="redirect(this.options.selectedIndex)" >

    Remove the following function.

    function redirect(x){
    for (m=temp.options.length-1;m>0;m--)
    for (i=0;i<group[x].length;i++){
    temp.options[i]=new Option(group[x][i].text,group[x][i].value)
    Nobody is Perfect. I am Nobody.


    • #3
      The goal is: A user choose a region in the first box, then all departement in that region is shows in the second box.
      The user then choose departement.

      this is a part of a bigger form where users register and the result is saved on a database.

      If i remove onChange="redirect(this.options.selectedIndex)" then nothing works... the other part was no problem to remove.



      • #4
        ah.. my bad. The offending code is actually down below...

        function go(){

        This is the one that's asking your browser to move away...

        to disable this find the place where the function go() is called and remove the call.

        This would work too... but a leaves a mess of unused function calls.
        function go(){
        // location=temp.options[temp.selectedIndex].value
        Nobody is Perfect. I am Nobody.


        • #5
          Im with you

          When i paste the whole code in to my form, i got this error message:

          'temp.option' is null or not an object


          • #6