JavaScript - incluir bucle if en bucle for

 
Vista:
sin imagen de perfil
Val: 14
Ha aumentado su posición en 4 puestos en JavaScript (en relación al último mes)
Gráfica de JavaScript

incluir bucle if en bucle for

Publicado por SARA (11 intervenciones) el 01/03/2016 19:26:00
TENGO UNA TABLA DINAMICA EN DONDE QUIERO RECORRERLA Y MOSTRAR EL VALOR DE UNA COLUMNA EN UN ALERTA CON LA SIGUIENTE FUNCION. CUANDO AGREGO EL IF NO ME MUESTRA LO QUE TENGO EN EL INPUT.

function ocultarimprimir()
{
var filas = parseInt(document.getElementById("total_concepto").value)+1;

for (x = 1; x < filas; x++) {

var ide = document.getElementById("tipook"+x).value

if (ide = "EXTRANJERO") {
//document.getElementById("nacional").style.display = 'none';
alert("ext");
}
else
{
alert("nac");
}
}
}
Capture
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

incluir bucle if en bucle for

Publicado por arck (74 intervenciones) el 02/03/2016 10:01:57
dos cosas.

1.- ¿Puedes poner un poco del codigo html para que se haga pruebas y te podamos ayudar?

2.- Si es este el codigo exacto, ¿puedes probar a poner dos == en el fi?


1
if (ide == "EXTRANJERO")
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil
Val: 14
Ha aumentado su posición en 4 puestos en JavaScript (en relación al último mes)
Gráfica de JavaScript

incluir bucle if en bucle for

Publicado por sara (11 intervenciones) el 02/03/2016 15:22:50
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<script>
function ocultarimprimir()
{
	var filas = parseInt(document.getElementById("total_concepto").value)+1;
 
	for (x = 1; x < filas; x++) {
 
		var ide = document.getElementById("tipook"+x).value;
 
		if (ide == "EXTRANJERO") {
 
			document.getElementById("nacional").style.display = 'none';
 			document.getElementById("extranjero").style.display = 'block';
		}
		else
		{
			document.getElementById("nacional").style.display = 'block';
 			document.getElementById("extranjero").style.display = 'none';
		}
	}
}
 
</script>
</head>
 
<body onload="ocultarimprimir()">
<div id="tablabuscar">
  <form id="form1" name="form1" method="get" action="">
    <table width="528" border="0" >
      <tr>
      <td width="193" height="40">Busqueda por Transportista:</td>
        <td width="250"><input type="text" name="txtbuscarnombre" id="txtbuscarnombre" /></td>
        <td width="71" align="right"><input type="submit" name="buscar" id="buscar" value="Buscar" class="btn btn-primary btn-sm"  />
      </td>
    </tr>
    </table>
  </form>
</div>
<p></p>
<p><a href="agregar.php"><img border="0" src="../imagenes/nuevo.png"></a>
</p>
 
<table width="92%" class="table table-hover ajustarok" border="1" id="tablaproveedor">
  <tr id="color_encabezado">
    <td>ID</td>
    <td>FECHA</td>
    <td>TRANSPORTISTA</td>
    <td width="10%"># FACTURA</td>
    <td>DELIVERY TICKET</td>
    <td>TOTAL</td>
    <td width="6%">T. C.</td>
    <td width="2%">&nbsp;</td>
    <td width="2%">&nbsp;</td>
    <td width="2%">&nbsp;</td>
  </tr>
  <?php
  $indice = 0;
  do {
     $indice = $indice + 1;?>
    <tr>
      <td><?php echo $row_contrarecibostransportistas['id']; ?></td>
      <td><?php echo $row_contrarecibostransportistas['fecha_contrarecibo']; ?></td>
      <td><?php echo $row_contrarecibostransportistas['transportista']; ?></td>
      <td><?php echo $row_contrarecibostransportistas['folio_factura']; ?></td>
      <td><?php echo $row_contrarecibostransportistas['delivery_ticket']; ?></td>
      <td><?php echo $row_contrarecibostransportistas['costo']; ?></td>
      <td><?php echo $row_contrarecibostransportistas['tipocambio']; ?>
      <input type="hidden" id="tipook<?php echo $indice; ?>" name="tipook<?php echo $indice; ?>" value="<?php echo $row_contrarecibostransportistas['tipo']; ?>" /></td>
      <td><a href="editar.php?id=<?php echo $row_contrarecibostransportistas['id']; ?>"><img border="0" src="../imagenes/editar2.png" /></a></td>
      <td><a href="eliminar.php?id=<?php echo $row_contrarecibostransportistas['id']; ?>"><img border="0" src="../imagenes/delete2.png" /></a></td>
      <td><a href="plantilla_contrarecibotransportista2.php?id=<?php echo $row_contrarecibostransportistas['id']; ?>" target="_blank"><img border="0" src="../imagenes/mex.png" id="nacional"></a><a href="plantilla_contrarecibotransportista.php?id=<?php echo $row_contrarecibostransportistas['id']; ?>" target="_blank"><img border="0" src="../imagenes/usd.png" id="extranjero" /></a></td>
    </tr>
    <?php } while ($row_contrarecibostransportistas = mysql_fetch_assoc($contrarecibostransportistas)); ?>
</table>
 
<input type="text" id="total_concepto" name="total_concepto" value="<?php echo $indice; ?>">
 
<table border="0">
  <tr>
    <td>Registros <?php echo ($startRow_contrarecibostransportistas + 1) ?> a <?php echo min($startRow_contrarecibostransportistas + $maxRows_contrarecibostransportistas, $totalRows_contrarecibostransportistas) ?> de <?php echo $totalRows_contrarecibostransportistas ?></td>
    <td width="5%" class="tablapaginador2"><?php if ($pageNum_contrarecibostransportistas > 0) { // Show if not first page ?>
        <a href="<?php printf("%s?pageNum_contrarecibostransportistas=%d%s", $currentPage, 0, $queryString_contrarecibostransportistas); ?>">Primero</a>
        <?php } // Show if not first page ?></td>
    <td width="5%" class="tablapaginador2"><?php if ($pageNum_contrarecibostransportistas > 0) { // Show if not first page ?>
        <a href="<?php printf("%s?pageNum_contrarecibostransportistas=%d%s", $currentPage, max(0, $pageNum_contrarecibostransportistas - 1), $queryString_contrarecibostransportistas); ?>">Anterior</a>
        <?php } // Show if not first page ?></td>
    <td width="5%" class="tablapaginador"><?php if ($pageNum_contrarecibostransportistas < $totalPages_contrarecibostransportistas) { // Show if not last page ?>
        <a href="<?php printf("%s?pageNum_contrarecibostransportistas=%d%s", $currentPage, min($totalPages_contrarecibostransportistas, $pageNum_contrarecibostransportistas + 1), $queryString_contrarecibostransportistas); ?>">Siguiente</a>
        <?php } // Show if not last page ?></td>
    <td width="5%" class="tablapaginador"><?php if ($pageNum_contrarecibostransportistas < $totalPages_contrarecibostransportistas) { // Show if not last page ?>
        <a href="<?php printf("%s?pageNum_contrarecibostransportistas=%d%s", $currentPage, $totalPages_contrarecibostransportistas, $queryString_contrarecibostransportistas); ?>">&Uacute;ltimo</a>
        <?php } // Show if not last page ?></td>
  </tr>
</table>
</p>
</body>
</html>
<?php
mysql_free_result($contrarecibostransportistas);
 
mysql_free_result($tipo);
?>
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de anonymus

incluir bucle if en bucle for

Publicado por anonymus (10 intervenciones) el 02/03/2016 17:48:12
Saludos arck
mañana de 8 a 11 voy a necesitar que me resuelvas unas dudas vas a poderme ayudar en el acto
AVISO QUE ES UN GRAN RETO como programador y nos beneficiaria a los dos.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
-1
Comentar

incluir bucle if en bucle for

Publicado por arck (74 intervenciones) el 02/03/2016 21:18:13
¿tu crees que los dos sacaremos beneficios?
Mira que lo dudo.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil
Val: 14
Ha aumentado su posición en 4 puestos en JavaScript (en relación al último mes)
Gráfica de JavaScript

incluir bucle if en bucle for

Publicado por sara (11 intervenciones) el 02/03/2016 22:34:51
arck me puedes ayudar con mi problema?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

incluir bucle if en bucle for

Publicado por arck (74 intervenciones) el 02/03/2016 23:44:15
si me pones el html generado puedo intentarlo pero con php yo no se
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

incluir bucle if en bucle for

Publicado por arck (74 intervenciones) el 03/03/2016 11:31:33
Haciendo unas pocas modificaciones.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<html>
    <head>
 
    </head>
    <body>
        <table>
            <tr align="center" class="letraChica" >
                <td>
                    <input id="tipook1" value="extranjero">
                </td>
                <td>
                    <input id="tipook2" value="nacional">
                </td>
                <td>
                    <input id="tipook3" value="importacion">
                </td>
            </tr>
        </table>
        <button onclick="ocultarImprimir()">Ocultar</button>
 
        <script type="text/javascript">
            function ocultarImprimir(){
                var filas = 3;
 
                for (x = 1; x <= filas; x++) {
 
                    var ide = document.getElementById("tipook"+x).value
 
                    alert(document.getElementById("tipook"+x).value);
                }
            }
        </script>
    </body>
</html>

pero en php no puedo ayudarte :(
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil
Val: 14
Ha aumentado su posición en 4 puestos en JavaScript (en relación al último mes)
Gráfica de JavaScript

incluir bucle if en bucle for

Publicado por sara (11 intervenciones) el 03/03/2016 16:23:40
ya pude resolverlo gracias
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar