• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 256
  • Last Modified:

Problems in Region Using javascript

hello,
why im getting two error in IE and with mozilla i dont get any error
i cant find the error in my code. this is what i have


<html>
<head>
<title>appl</title>
<style type="text/css">
<!--
.style10 {font-family: verdana; font-size: 9pt; color: #000000; }
.style11 {color: #000000 }
.style13 {font-family: verdana; font-size: 9pt; color: #000000; font-weight: bold; }
-->
</style>
</head>
<body>
<FORM NAME="Form1" ACTION="post.php" METHOD="POST">
  <table width="550" border="1" align="center" cellspacing="0" bordercolor="#FFFFFF" style="border-collapse: collapse">
    <tr>
      <td width="213" align="right"><span class="style10"> band: </span></td>
      <td align="left" width="641">
        <input name="Band_Name" type="text" id="Band_Name" size="20">
      </td>
    </tr>
    <tr>
      <td width="213" align="right"><span class="style10">genere: </span></td>
      <td align="left" width="641">
        <input name="Genero" type="text" id="Genero" size="20">
      </td>
    </tr>
    <tr>
      <td width="213" align="right"><span class="style10">year: </span></td>
      <td align="left" width="641">
        <input name="Year" type="text" id="Year" size="20">
      </td>
    </tr>
    <tr>
      <td width="213" align="right"><span class="style10"> Email: </span></td>
      <td align="left" width="641">
        <input name="Email" type="text" id="Email" size="20">
      </td>
    </tr>
    <tr>
      <td width="213" align="right"><span class="style10"> location:</span></td>
      <td width="641">
        <span class="style10">
        <select name="txtregion1" id="txtRegion1" onChange="javascript:SelectRegion(2)">
          <option value=0>Selecciona la Provincia</option>
        </select>
        <nobr>
        <select name="txtregion2" id="txtRegion2" width="20">
          <option value=0>Selecciona la Ciudad</option>
        </select>
        <br>
      Selecciona el Departamento y la Ciudad en que vives.<br>
      Si tu ubicaci&oacute;n no figura, puedes seleccionar la <br>
      m&aacute;s cercana y aclararlo en el campo de aqu&iacute; abajo.<br>
      <input maxlength="40" size="25" name="txtRegion3" value="">
        </span></td>
    </tr>
    <tr>
      <td width="213" align="right"><span class="style10"> phone: </span></td>
      <td align="left" width="641">
        <input name="Phone" type="text" id="Phone" size="20">
      </td>
    </tr>
    <tr>
      <td width="213" align="right"><span class="style10"> Members:</span></td>
      <td align="left" width="641">
        <span class="style10">
        <textarea name="Miembros" cols="43" rows="4" id="Miembros"></textarea>
      </span>      </td>
    </tr>
    <tr>
      <td width="213" align="right"><span class="style10"> Biogra:</span></td>
      <td align="left" width="641">
        <span class="style10">
        <textarea name="Biografia" cols="43" rows="4" id="Biografia"></textarea>
      </span>      </td>
    </tr>
    <tr>
      <td width="213" align="right"><span class="style10"> addr: </span></td>
      <td align="left" width="641">
        <input name="Direccion" type="text" id="Direccion" size="20">
      </td>
    </tr>
  <tr>
  <td width="213" align="right"><span class="style10">Web: </span></td>
      <td align="left" width="641">
        <input name="Web" type="text" id="Web" value="http://" size="20">
      </td>
  </tr>
  <tr>
    <td align="left" width="213"><span class="style11"></span> </td>
    <td align="left" width="641">
      <input name="submit" type="submit" value="ENVIAR!">
  </tr>
  </table>
</FORM>
<script language="JavaScript" src="/javascript_regiones.js"></script>
<script>

//Cargo las regiones
//Recupero la seleccion del usuario
   SelectRegion(1);

   SelectRegion(2);

//Recupero el tipo de documento

  function optregion() {
        var argv = optregion.arguments;
        var argc = argv.length;
        var n = 0;
        switch(argv[0]) {
              case 1:
                    for (var k = 1; k < argc; k+=2)
                          document.Form1.txtregion1.options[n++] = new Option(argv[k], argv[k+1]);
                    document.Form1.txtregion1.selectedIndex = 0;
                    break;
              case 2:
                    for (var k = 1; k < argc; k+=2)
                          document.Form1.txtregion2.options[n++] = new Option(argv[k], argv[k+1]);
                    document.Form1.txtregion2.selectedIndex = 0;
                    break;
        }
  }
</script>
</body>
</html>
0
Xtry
Asked:
Xtry
  • 9
  • 6
1 Solution
 
archrajanCommented:
can u post this file?
javascript_regiones.js
0
 
archrajanCommented:
Also to find the error in firefox
please see the

Tool-> Javascript console

for all javascript errors
0
 
XtryAuthor Commented:
my javascript_regiones.js file
----

function SelectRegion(niv) {
var si;
if (niv==1){
document.Form1.txtregion1.selectedIndex=0;
document.Form1.txtregion1.length=0;
document.Form1.txtregion1.disabled=0;
optregion(1,'Selecciona un Departamento ','0','Distrito Capital','51','Antioquia','83','Amazonas','52','Arauca','53','Atlantico','54','Bolivar','55','Boyacá','56','Caldas','57','Caquetá','58','Casanáre','59','Cauca','60','Cesár','61','Chocó','62','Córdoba','63','Cundinamarca','64','Guajira','66','Guaviare','67','Huila','68','Magdalena','69','Meta','70','Nariño','71','Norte de Santander','72','Putumayo','73','Quindio','74','Risaralda','75','San Andres Islas','76','Santander','77','Sucre','78','Tolima','79','Valle del Cauca','80','Vaupés','81','Vichada','82');
}else{
document.Form1.txtregion2.selectedIndex=0;
si=document.Form1.txtregion1.selectedIndex;
region=parseInt(document.Form1.txtregion1[si].value);
var op=0;
document.Form1.txtregion2.length=0;
document.Form1.txtregion2.disabled=0;
switch(region){
case 0:
optregion(2,'Selecciona una Ciudad','0');
break;
case 51:
optregion(2,'Santafé de Bogotá','501');
break;
case 83:
optregion(2,'Apartadó','505','Envigado','506','Itagüí','507','Medellín','504','Turbo','508');
break;
case 52:
optregion(2,'Leticia','502','Puerto Nariño','503');
break;
case 53:
optregion(2,'Arauca','509','Arauquita','510','Puerto Rondón','511','Saravena','512','Tame','513');
break;
case 54:
optregion(2,'Baranoa','515','Barranquilla','514','Campo de la Cruz','516','Candelaria','517','Ciudad capital','518','Galapa','519','Juan de Acosta','520','Luruaco','521','Malambo','522','Manatí','523','Palmar de Valera','524','Piojó','525','Polonuevo','526','Ponedera','527','Puerto Colombia','528','Repelón','529','Sabanagrande','530','Sabanalarga','531','Santa Lucía','532','Santo Tomás','533','Soledad','534','Suan','535','Tubará','536','Usiacurí','537');
break;
case 55:
optregion(2,'Cartagena','538','Mompós','539','Tumaco','540','Villanueva','541','Zambrano','542');
break;
case 56:
optregion(2,'Chiquinquirá','544','Duitama','545','Sogamoso','546','Tunja','543','Villa de Leyva','547');
break;
case 57:
optregion(2,'Filadelfia','549','La Dorada','550','Manizales','548','Marquetalia','551','Salamina','552');
break;
case 58:
optregion(2,'Cartagena del Chairá','554','Florencia','555','San José de Fragua','556','San Vicente del Caguán','553','Valparaíso','557');
break;
case 59:
optregion(2,'Hato Corozal','559','Monterrey','560','Sabanalarga','561','Villanueva','562','Yopal','558');
break;
case 60:
optregion(2,'Bolívar','564','Florencia','565','Popayán','563','Santa Rosa','566','Santander de Quilichao','567');
break;
case 61:
optregion(2,'Aguachica','569','Pailitas','570','San Alberto','571','San Martín','572','Valledupar','568');
break;
case 62:
optregion(2,'Bahía Solano (Ciudad Mutis)','574','Juradó','575','Litoral del San Juan','576','Nuquí','577','Quibdó','573');
break;
case 63:
optregion(2,'Montería','578','San Andrés de Sotavento','580','San Carlos','581','Sinú','579','Valencia','582');
break;
case 64:
optregion(2,'Cajicá','583','Chía','584','Fusagasugá','585','La Calera','586','Zipaquirá','587');
break;
case 66:
optregion(2,'Fonseca','590','Maicao','591','Rioacha','589','Urumita','592','Villanueva','593');
break;
case 67:
optregion(2,'Calamar','597','El Retorno','595','Miraflores','596','San José del Guaviare','594');
break;
case 68:
optregion(2,'Garzón','599','La Plata','600','Neiva','598','Pitalito','601','Rivera','602');
break;
case 69:
optregion(2,'El Banco','604','Fundación','605','Plato','606','Santa Marta','603','Tenerife','607');
break;
case 70:
optregion(2,'Villavicencio','608');
break;
case 71:
optregion(2,'Ipiales','610','Pasto','609');
break;
case 72:
optregion(2,'Cúcuta','611','Ocaña','612','Pamplona','613','San Cayetano','614','Villa del Rosario','615');
break;
case 73:
optregion(2,'Colón','616','Mocoa','617','Orito','618','Puerto Asís','619','Villagarzón','620');
break;
case 74:
optregion(2,'Armenia','621','Buenavista','622','Calarcá','623','Circasia','624','Filandia','625','Quimbaya','626');
break;
case 75:
optregion(2,'Apía','628','Balboa','629','Belén de Umbría','630','Dosquebradas','631','Guática','632','La Celia','633','La Virginia','634','Marsella','635','Mistrató','636','Pereira','627','Pueblo Rico','637','Quinchía','638','Santa Rosa de Cabal','639','Santuario','640');
break;
case 76:
optregion(2,'Providencia','641','San Andres','642');
break;
case 77:
optregion(2,'Barrancabermeja','644','Bucaramanga','643','Girón','645','Socorro','646','Sucre','647');
break;
case 78:
optregion(2,'Buenavista','649','Corozal','650','Sincé','651','Sincelejo','648','Tolú','652');
break;
case 79:
optregion(2,'Carmen de Apicalá','654','El Espinal','655','Ibagué','653','Mariquita','656','Melgar','657');
break;
case 80:
optregion(2,'Buenaventura','659','Buga','660','Cali','658','Roldanillo','661','Tuluá','662');
break;
case 81:
optregion(2,'Carurú','664','Mitú','663','Taraira','665');
break;
case 82:
optregion(2,'La Primavera','667','Puerto Carreño','666','Santa Rosalía','668');
break;
}
}

}
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
XtryAuthor Commented:
can anyone help me?
0
 
archrajanCommented:
Oops i forgot abt this one..
let me have a look now..
sorry abt the wait
0
 
archrajanCommented:
See this works::

<html>
<head>
<title>appl</title>
<style type="text/css">
<!--
.style10 {font-family: verdana; font-size: 9pt; color: #000000; }
.style11 {color: #000000 }
.style13 {font-family: verdana; font-size: 9pt; color: #000000; font-weight: bold; }
-->
</style>
</head>
<body>
<FORM NAME="Form1" ACTION="post.php" METHOD="POST">
  <table width="550" border="1" align="center" cellspacing="0" bordercolor="#FFFFFF" style="border-collapse: collapse">
    <tr>
      <td width="213" align="right"><span class="style10"> band: </span></td>
      <td align="left" width="641">
        <input name="Band_Name" type="text" id="Band_Name" size="20">
      </td>
    </tr>
    <tr>
      <td width="213" align="right"><span class="style10">genere: </span></td>
      <td align="left" width="641">
        <input name="Genero" type="text" id="Genero" size="20">
      </td>
    </tr>
    <tr>
      <td width="213" align="right"><span class="style10">year: </span></td>
      <td align="left" width="641">
        <input name="Year" type="text" id="Year" size="20">
      </td>
    </tr>
    <tr>
      <td width="213" align="right"><span class="style10"> Email: </span></td>
      <td align="left" width="641">
        <input name="Email" type="text" id="Email" size="20">
      </td>
    </tr>
    <tr>
      <td width="213" align="right"><span class="style10"> location:</span></td>
      <td width="641">
        <span class="style10">
        <select name="txtregion1" id="txtRegion1" onChange="javascript:SelectRegion(2)">
          <option value=0>Selecciona la Provincia</option>
        </select>
        <nobr>
        <select name="txtregion2" id="txtRegion2" width="20">
          <option value=0>Selecciona la Ciudad</option>
        </select>
        <br>
      Selecciona el Departamento y la Ciudad en que vives.<br>
      Si tu ubicaci&oacute;n no figura, puedes seleccionar la <br>
      m&aacute;s cercana y aclararlo en el campo de aqu&iacute; abajo.<br>
      <input maxlength="40" size="25" name="txtRegion3" value="">
        </span></td>
    </tr>
    <tr>
      <td width="213" align="right"><span class="style10"> phone: </span></td>
      <td align="left" width="641">
        <input name="Phone" type="text" id="Phone" size="20">
      </td>
    </tr>
    <tr>
      <td width="213" align="right"><span class="style10"> Members:</span></td>
      <td align="left" width="641">
        <span class="style10">
        <textarea name="Miembros" cols="43" rows="4" id="Miembros"></textarea>
      </span>      </td>
    </tr>
    <tr>
      <td width="213" align="right"><span class="style10"> Biogra:</span></td>
      <td align="left" width="641">
        <span class="style10">
        <textarea name="Biografia" cols="43" rows="4" id="Biografia"></textarea>
      </span>      </td>
    </tr>
    <tr>
      <td width="213" align="right"><span class="style10"> addr: </span></td>
      <td align="left" width="641">
        <input name="Direccion" type="text" id="Direccion" size="20">
      </td>
    </tr>
  <tr>
  <td width="213" align="right"><span class="style10">Web: </span></td>
      <td align="left" width="641">
        <input name="Web" type="text" id="Web" value="http://" size="20">
      </td>
  </tr>
  <tr>
    <td align="left" width="213"><span class="style11"></span> </td>
    <td align="left" width="641">
      <input name="submit" type="submit" value="ENVIAR!">
  </tr>
  </table>
</FORM>
<script>

function SelectRegion(niv) {
var si;
if (niv==1){
document.Form1.txtregion1.selectedIndex=0;
document.Form1.txtregion1.length=0;
document.Form1.txtregion1.disabled=0;
optregion(1,'Selecciona un Departamento ','0','Distrito Capital','51','Antioquia','83','Amazonas','52','Arauca','53','Atlantico','54','Bolivar','55','Boyacá','56','Caldas','57','Caquetá','58','Casanáre','59','Cauca','60','Cesár','61','Chocó','62','Córdoba','63','Cundinamarca','64','Guajira','66','Guaviare','67','Huila','68','Magdalena','69','Meta','70','Nariño','71','Norte de Santander','72','Putumayo','73','Quindio','74','Risaralda','75','San Andres Islas','76','Santander','77','Sucre','78','Tolima','79','Valle del Cauca','80','Vaupés','81','Vichada','82');
}else{
document.Form1.txtregion2.selectedIndex=0;
si=document.Form1.txtregion1.selectedIndex;
region=parseInt(document.Form1.txtregion1[si].value);
var op=0;
document.Form1.txtregion2.length=0;
document.Form1.txtregion2.disabled=0;
switch(region){
case 0:
optregion(2,'Selecciona una Ciudad','0');
break;
case 51:
optregion(2,'Santafé de Bogotá','501');
break;
case 83:
optregion(2,'Apartadó','505','Envigado','506','Itagüí','507','Medellín','504','Turbo','508');
break;
case 52:
optregion(2,'Leticia','502','Puerto Nariño','503');
break;
case 53:
optregion(2,'Arauca','509','Arauquita','510','Puerto Rondón','511','Saravena','512','Tame','513');
break;
case 54:
optregion(2,'Baranoa','515','Barranquilla','514','Campo de la Cruz','516','Candelaria','517','Ciudad capital','518','Galapa','519','Juan de Acosta','520','Luruaco','521','Malambo','522','Manatí','523','Palmar de Valera','524','Piojó','525','Polonuevo','526','Ponedera','527','Puerto Colombia','528','Repelón','529','Sabanagrande','530','Sabanalarga','531','Santa Lucía','532','Santo Tomás','533','Soledad','534','Suan','535','Tubará','536','Usiacurí','537');
break;
case 55:
optregion(2,'Cartagena','538','Mompós','539','Tumaco','540','Villanueva','541','Zambrano','542');
break;
case 56:
optregion(2,'Chiquinquirá','544','Duitama','545','Sogamoso','546','Tunja','543','Villa de Leyva','547');
break;
case 57:
optregion(2,'Filadelfia','549','La Dorada','550','Manizales','548','Marquetalia','551','Salamina','552');
break;
case 58:
optregion(2,'Cartagena del Chairá','554','Florencia','555','San José de Fragua','556','San Vicente del Caguán','553','Valparaíso','557');
break;
case 59:
optregion(2,'Hato Corozal','559','Monterrey','560','Sabanalarga','561','Villanueva','562','Yopal','558');
break;
case 60:
optregion(2,'Bolívar','564','Florencia','565','Popayán','563','Santa Rosa','566','Santander de Quilichao','567');
break;
case 61:
optregion(2,'Aguachica','569','Pailitas','570','San Alberto','571','San Martín','572','Valledupar','568');
break;
case 62:
optregion(2,'Bahía Solano (Ciudad Mutis)','574','Juradó','575','Litoral del San Juan','576','Nuquí','577','Quibdó','573');
break;
case 63:
optregion(2,'Montería','578','San Andrés de Sotavento','580','San Carlos','581','Sinú','579','Valencia','582');
break;
case 64:
optregion(2,'Cajicá','583','Chía','584','Fusagasugá','585','La Calera','586','Zipaquirá','587');
break;
case 66:
optregion(2,'Fonseca','590','Maicao','591','Rioacha','589','Urumita','592','Villanueva','593');
break;
case 67:
optregion(2,'Calamar','597','El Retorno','595','Miraflores','596','San José del Guaviare','594');
break;
case 68:
optregion(2,'Garzón','599','La Plata','600','Neiva','598','Pitalito','601','Rivera','602');
break;
case 69:
optregion(2,'El Banco','604','Fundación','605','Plato','606','Santa Marta','603','Tenerife','607');
break;
case 70:
optregion(2,'Villavicencio','608');
break;
case 71:
optregion(2,'Ipiales','610','Pasto','609');
break;
case 72:
optregion(2,'Cúcuta','611','Ocaña','612','Pamplona','613','San Cayetano','614','Villa del Rosario','615');
break;
case 73:
optregion(2,'Colón','616','Mocoa','617','Orito','618','Puerto Asís','619','Villagarzón','620');
break;
case 74:
optregion(2,'Armenia','621','Buenavista','622','Calarcá','623','Circasia','624','Filandia','625','Quimbaya','626');
break;
case 75:
optregion(2,'Apía','628','Balboa','629','Belén de Umbría','630','Dosquebradas','631','Guática','632','La Celia','633','La Virginia','634','Marsella','635','Mistrató','636','Pereira','627','Pueblo Rico','637','Quinchía','638','Santa Rosa de Cabal','639','Santuario','640');
break;
case 76:
optregion(2,'Providencia','641','San Andres','642');
break;
case 77:
optregion(2,'Barrancabermeja','644','Bucaramanga','643','Girón','645','Socorro','646','Sucre','647');
break;
case 78:
optregion(2,'Buenavista','649','Corozal','650','Sincé','651','Sincelejo','648','Tolú','652');
break;
case 79:
optregion(2,'Carmen de Apicalá','654','El Espinal','655','Ibagué','653','Mariquita','656','Melgar','657');
break;
case 80:
optregion(2,'Buenaventura','659','Buga','660','Cali','658','Roldanillo','661','Tuluá','662');
break;
case 81:
optregion(2,'Carurú','664','Mitú','663','Taraira','665');
break;
case 82:
optregion(2,'La Primavera','667','Puerto Carreño','666','Santa Rosalía','668');
break;
}
}

}

</script>
<script>

//Cargo las regiones
//Recupero la seleccion del usuario
   SelectRegion(1);

   SelectRegion(2);

//Recupero el tipo de documento

  function optregion() {
       var argv = optregion.arguments;
       var argc = argv.length;
       var n = 0;
       switch(argv[0]) {
            case 1:
                 for (var k = 1; k < argc; k+=2)
                         {
                  document.Form1.txtregion1.options[n++] = new Option(argv[k], argv[k+1]);
                 document.Form1.txtregion1.selectedIndex = 0;
                         }
                 break;
                         
            case 2:
                 for (var k = 1; k < argc; k+=2)
                         {
                      document.Form1.txtregion2.options[n++] = new Option(argv[k], argv[k+1]);
                 document.Form1.txtregion2.selectedIndex = 0;
                         }
                 break;
       }
  }
</script>
</body>
</html>
0
 
XtryAuthor Commented:
im getting this errors with IE

Line 104
char 158

then

Line 222
Char 4
0
 
archrajanCommented:
Xtry
There is no problem in the code i posted
see it here:
http://www.archanapatchirajan.com/EEREGIONPROBLEM.html

it does not give any error in firefox and IE
0
 
XtryAuthor Commented:
ok this is weird, why is that?
when I use mozilla I see instead of "Boyacá" I see "Boyac?"
And when I try with IE I just get errors
0
 
archrajanCommented:
Which version of IE r u using?

becaue  i tested my link in IE6 and FIREFOX  and NETSCAPE 7.1
I see no error at all..

Also, for that special character u entity code respective of that character
0
 
XtryAuthor Commented:
mozilla v1.0.3
IE v6
0
 
archrajanCommented:
It works for me in both the browsers!
0
 
XtryAuthor Commented:
Im sorry I tested you code and It works pretty good.
no errors with IE no errors with mozilla
why im getting errors from my server ?
0
 
archrajanCommented:
i am clueless of how come this cud happen...
check what encoding u r usin in ur browser?
0
 
archrajanCommented:
i am not sure abt whats happening in ur server...

please post the view source from there
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 9
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now