Foros del Web » Programando para Internet » Javascript »

Comodines con getElementById()

Estas en el tema de Comodines con getElementById() en el foro de Javascript en Foros del Web. Saludos nuevamente Es posible utilizar algun tipo de comodin con la funcion getElementById() ? Necesito obtener todos los campos de texto que su ID empiece ...
  #1 (permalink)  
Antiguo 18/04/2006, 11:55
 
Fecha de Ingreso: septiembre-2004
Mensajes: 40
Antigüedad: 19 años, 7 meses
Puntos: 0
Pregunta Comodines con getElementById()

Saludos nuevamente

Es posible utilizar algun tipo de comodin con la funcion getElementById() ?

Necesito obtener todos los campos de texto que su ID empiece con la palabra 'precio'. Probé de esta manera pero no funcionó

document.getElementById("precio*");

Alguien tiene alguna idea?

Gracias y saludos
  #2 (permalink)  
Antiguo 18/04/2006, 12:21
Avatar de Saruman  
Fecha de Ingreso: mayo-2003
Ubicación: Panama city, Panama, Panama
Mensajes: 1.154
Antigüedad: 21 años
Puntos: 5
se me ocurre esto para ti:

Código PHP:
<script language="javascript">
 function 
GetComodines() {
  var 
inputs document.getElementsByTagName("input");
  for (
i=0inputs.lengthi++) {
   if (
inputs[i].type == "text") {
    if (
inputs[i].name.substring(06) == "precio") {
     
alert(inputs[i].value);
    }
   }
  }
 }
 
 
window.onload = function() {
  
GetComodines();
 }
</script> 
Código HTML:
<input type="text" name="precio1" id="precio1" value="1">
<input type="text" name="precio2" id="precio2" value="2">
<input type="text" name="precio3" id="precio3" value="3">
<input type="text" name="precio4" id="precio4" value="4">
<input type="text" name="precio5" id="precio5" value="5"> 
saludos
__________________
Saruman

One Ring to rule them all, One Ring to find them, One Ring to bring them all and in the darkness bind them.
  #3 (permalink)  
Antiguo 18/04/2006, 13:43
 
Fecha de Ingreso: septiembre-2004
Mensajes: 40
Antigüedad: 19 años, 7 meses
Puntos: 0
Gracias Saruman!

Eso me sirve de mucho

Saludos
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:00.