Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/06/2016, 13:37
webtexcoco
 
Fecha de Ingreso: febrero-2016
Mensajes: 43
Antigüedad: 8 años, 2 meses
Puntos: 2
Error funcion habilita y deshabilita removeAttribute is not a function

hola que tal compañeros

me ando iniciando en javascript, estoy tratando de hacer una funcion que me habilite y deshabilite cierto grupo de campos de texto mi función que tengo es esta

Código Javascript:
Ver original
  1. function seleccion(cualidades,propiedades,selec){
  2.  
  3.             var rad = document.getElementById(selec);
  4.  
  5.             if(rad.checked){
  6.                 document.getElementsByName(cualidades).removeAttribute('disabled', 'disabled');
  7.                 document.getElementsByName(propiedades).removeAttribute('disabled', 'disabled');
  8.             }else{
  9.                 document.getElementsByName(cualidades).setAttribute('disabled', 'disabled');
  10.                 document.getElementsByName(propiedades).setAttribute('disabled', 'disabled');
  11.             }
  12.         }

y mi html es este

Código HTML:
Ver original
  1. <table border="1">
  2.         <tr>
  3.             <th>A</th>
  4.             <th>B</th>
  5.         </tr>
  6.         <tr>
  7.             <td>
  8.                 <p>Cualidades 1<br>
  9.                     <input type="text" name="cualidades1[]" disabled><br>
  10.                     <input type="text" name="cualidades1[]" disabled><br>
  11.                     <input type="text" name="cualidades1[]" disabled><br>
  12.                     <input type="text" name="cualidades1[]" disabled><br>
  13.                     <input type="text" name="cualidades1[]" disabled><br>
  14.                 </p>
  15.                 <p>Propiedades 1<br>
  16.                     <input type="text" name="propiedades1[]" disabled><br>
  17.                     <input type="text" name="propiedades1[]" disabled><br>
  18.                     <input type="text" name="propiedades1[]" disabled><br>
  19.                     <input type="text" name="propiedades1[]" disabled><br>
  20.                     <input type="text" name="propiedades1[]" disabled><br>
  21.                     <input type="radio" id="1" onclick="seleccion('cualidades1[]','propiedades1[]','1')" name="opcion">
  22.                 </p>
  23.             </td>
  24.             <td>
  25.                 <p>Cualidades 2<br>
  26.                     <input type="text" name="cualidades2[]" disabled><br>
  27.                     <input type="text" name="cualidades2[]" disabled><br>
  28.                     <input type="text" name="cualidades2[]" disabled><br>
  29.                     <input type="text" name="cualidades2[]" disabled><br>
  30.                     <input type="text" name="cualidades2[]" disabled><br>
  31.                 </p>
  32.                 <p>Propiedades 2<br>
  33.                     <input type="text" name="propiedades2[]" disabled><br>
  34.                     <input type="text" name="propiedades2[]" disabled><br>
  35.                     <input type="text" name="propiedades2[]" disabled><br>
  36.                     <input type="text" name="propiedades2[]" disabled><br>
  37.                     <input type="text" name="propiedades2[]" disabled><br>
  38.                     <input type="radio" id="2" onclick="seleccion('cualidades2[]','propiedades2[]','2')" name="opcion">
  39.                 </p>
  40.             </td>
  41.         </tr>
  42.     </table>

la idea es que cuando presione el botón radio se habilite uno u otro grupo de campos de texto,
pero al darle click al radio javascript me arroja este error

Uncaught TypeError: document.getElementsByName(...).removeAttribute is not a function

he tratado de buscar y buscar pero no hallo que estoy haciendo mal.

que puede estar pasando? alguna idea? no se mucho sobre javascript, ojala puedan orientarme un poco

*mando los parámetros de la función porque estos campos vienen de una base de datos

gracias por tu ayuda!!!