Foros del Web » Programando para Internet » Javascript »

Problema al tomar valor de variable

Estas en el tema de Problema al tomar valor de variable en el foro de Javascript en Foros del Web. ESTIMADOS(AS), TENGO EL SIGUIENTE PROBLEMA, SOY UN POCO NUEVO EN JAVASCRIPT Y QUIERO TOMAR EL VALOR DE UN ARREGLO, LO QUE QUIERO ES VER CUAL ...
  #1 (permalink)  
Antiguo 13/12/2013, 07:40
 
Fecha de Ingreso: junio-2012
Ubicación: Santiago de Chile
Mensajes: 164
Antigüedad: 11 años, 10 meses
Puntos: 1
Problema al tomar valor de variable

ESTIMADOS(AS), TENGO EL SIGUIENTE PROBLEMA, SOY UN POCO NUEVO EN JAVASCRIPT Y QUIERO TOMAR EL VALOR DE UN ARREGLO, LO QUE QUIERO ES VER CUAL SE PRESIONA...

Código PHP:

<?for ($i=0$i<$cant_marcas$i++){?>
<div style="width: 80%; border: 1px solid #ccc; margin: 10px;"><?php echo $marcas[$i]['marca']?>
<a style="margin: 0 0 0 200px; cursor: pointer;" onclick="selecciona()">Editar</a>
<input type="hidden" name="numero" id="numero[]" value="<?php echo $marcas[$i]['id'];?>" />
</div>
<?php }?>
SI SE FIJAN IMPRIMO EN PANTALLA CON UN FOR LOS SIGUIENTES DATOS...RESULTA QUE AL LADO DE CADA MARCA HAY UN EDITAR, AL PRESIONAR ESE EDITAR ENVÍO LA VARIABLE A UN IFRAME QUE SE SITUA JUSTO ABAJO DE LO QUE IMPRIMO...ESTOY TRATANDO DE ENVIAR EL VALOR AL IFRAME, PERO SÓLO RECOJO EL PRIMER VALOR, OSEA EL PRIMER ID QUE SE IMPRIME


Código Javascript:
Ver original
  1. <script>
  2. function selecciona(valor){    
  3.     var ide = document.getElementById("numero").value;    
  4.     parent.edita.location.href='edita.php?id='+ ide;
  5. }
  6. </script>

TENGO UNA FUNCIÓN ASÍ, Y ME ENVIA BIEN EL VALOR, PERO NECESITO ENVIAR DEPENDIENDO DE CUAL SE PRESIONE, NO SE SI ME EXPLICO BIEN...SI ALGUIEN ME PUEDE AYUDAR, LO AGRADECERÍA MUCHO


SALUDOS
  #2 (permalink)  
Antiguo 13/12/2013, 09:11
Avatar de IsaBelM
Colaborador
 
Fecha de Ingreso: junio-2008
Mensajes: 5.032
Antigüedad: 15 años, 10 meses
Puntos: 1012
Respuesta: Problema al tomar valor de variable

cometes un varios errores
  • las ids han de ser únicas y como tal no pueden ser tratadas como array
  • a la función no le pasas ningún parámetro

para esto último, prueba con el método nextElementSibling()
__________________
if(ViolenciaDeGénero) {alert('MUJER ASESINADA');}

Etiquetas: input, php, tomar, valor, variable
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 08:48.