PHP - Tengo una pagina con un formulario pero no el boton no esta funcioando

 
Vista:

Tengo una pagina con un formulario pero no el boton no esta funcioando

Publicado por federico (2 intervenciones) el 28/09/2018 15:02:37
Ayudaaa!!!! eh visto de todo pero el boton no esta funcionando dejo el codigo de ante mano muchas gracias

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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
<?
include('index2.php');
?>
<script src="jquery.js" type="text/javascript"></script>
<script src="jquery-3.1.1.min.js" type="text/javascript"></script>
<script type="text/javascript" src="functions.js"></script>
<script type="text/javascript">
  $(document).ready(function(){
    $("#marca").change(function(){
    $.ajax({
      url:"subcategorias2.php",
      type: "POST",
      data:"idmarca="+$("#marca").val(),
      success: function(opciones){
        $("#modelo").html(opciones);
      }
    })
  });
});
</script>
<br/>
<center><div style="width:60%;"><h4 style="COLOR: #0404B4; BACKGROUND-COLOR: #D0FA58; opacity: 0.8">Ver Aviso Auditado</h4></div></center><br/>
<br/>
 
<?
$id_p = $_GET["id_p"];
 
 
 
 
 
function leerDirectorio($ruta){
if($dir = opendir($ruta)){
    chdir($ruta);
    //Creamos los array de archivos y carpetas 
    $archivos=array();
    $carpetas=array();
    //Leemos todos los elementos del directorio 
    while (($leerDir = readdir($dir)) !== false){
      if(!is_dir ($leerDir)) array_push($archivos,$leerDir);
        else array_push($carpetas,$leerDir);
    }
    //Mostrar Archivos 
 
    foreach($archivos as $aux)
    {
        ?>
 
        >
        <?
        /* Cerrar directorio */
        closedir($dir);
    }
}
 
function leerDirectorioTermino($ruta){
if($dir = opendir($ruta)){
chdir($ruta);
//Creamos los array de archivos y carpetas 
$archivos=array();
$carpetas=array();
//Leemos todos los elementos del directorio 
while (($leerDir = readdir($dir)) !== false){
  if(!is_dir ($leerDir)) array_push($archivos,$leerDir);
    else array_push($carpetas,$leerDir);
    }
  //Mostrar Archivos 
 
  foreach($archivos as $aux)
    {
    ?>
 
 
    <?
    /* Cerrar directorio */
    closedir($dir);
    }
}
 
 
 
 
$link = mysqli_connect("localhost","pcomp","xxx", "xxx");
$sql123 = "SELECT * FROM xxx where id = '$id'";
$result123 = mysql_query($sql123);
while ($row = mysql_fetch_array($result123)) {
 
  $area = $row["area_derivacion"];
?>
    <table align="center" class="table" style="width: 50%" >
<tr>
<td>Adjuntos de inicio</td>
<td><? echo @leerDirectorio($path2) ?></td>
</tr>
 
<tr>
<td>Adjuntos de termino</td>
<td><? echo @leerDirectorioTermino($path3) ?></td>
</tr>
 
</table><br/>
 
   <center><table id="tabla" class="table" align="center" style="width: auto">
  <tr>
  <?
$tipo_defecto = $row["tipo_defecto"];
$agencia = $row["agencia"];
$central = $row["central"];
$direccion = $row["direccion"];
$tipo_cable = $row["tipo_cable"];
$cable = $row["cable"];
$armario = $row["armario"];
$causa_falla = $row["causa_falla"];
 
 
?>
        <td>
            ID Aviso</td>
        <td>
           <input id="txtID_proy"  style="width:350px;" type="text" readonly="readonly"
                value="<?php echo $row["id_aviso"]; ?>" >
        </td>
    </tr>
    <tr>
    <td>
            tipo_defecto</td>
        <td>
           <input id="txtcalle0" style="width:350px;"  type="text" readonly="readonly"
                value="<?php echo utf8_encode($row["tipo_defecto"]); ?>" >
        </td>
    </tr>
    <tr>
        <td>
            Agencia
        </td>
        <td>
          <input id="txtaltura0" style="width:350px;"  type="text" value="<?php echo utf8_encode($row["agencia"]); ?>" ></td>
    </tr>
    <tr>
        <td>
            Oficina Central
        </td>
        <td>
         <input id="txthp0" type="text" style="width:350px;"  readonly="readonly"
                value="<?php echo $row["central"]; ?>" ></td>
    </tr>
 
    <tr>
        <td>
            Direccion                </td>
        <td>
            <input id="txtcap0" style="width:350px;"  readonly="readonly" type="text"
                value="<?php echo $row["direccion"]; ?>" ></td>
    </tr>
    <tr>
        <td>
            Tipo Cable
        </td>
        <td>
            <input id="txteecc0" style="width:350px;"  readonly="readonly" type="text"
                value="<?php echo utf8_encode($row["tipo_cable"]); ?>" ></td>
    </tr>
<tr>
        <td>
            Cable
        </td>
        <td>
            <input id="txteecc0" style="width:350px;"  readonly="readonly" type="text"
                value="<?php echo utf8_encode($row["cable"]); ?>" ></td>
    </tr>
    <tr>
        <td>
            Armario
        </td>
        <td>
            <input id="txteecc0" style="width:350px;"  readonly="readonly" type="text"
                value="<?php echo utf8_encode($row["armario"]); ?>" ></td>
    </tr>
    <tr>
        <td>
            Causa Falla
        </td>
        <td>
            <input id="txteecc0" style="width:350px;"  readonly="readonly" type="text"
                value="<?php echo utf8_encode($row["causa_falla"]); ?>" ></td>
    </tr>
    <tr>
        <td>
            Fecha Ingreso
        </td>
        <td>
            <input id="txteecc0" style="width:350px;"  readonly="readonly" type="text"
                value="<?php echo utf8_encode($row["fecha_ingreso"]); ?>" ></td>
    </tr>
    <tr>
        <td>
            Usuario Ingreso aviso
        </td>
        <td>
            <input id="txteecc0" style="width:350px;"  readonly="readonly" type="text"
                value="<?php echo utf8_encode($row["usuario_ingreso_aviso"]); ?>" ></td>
    </tr>
    <tr>
        <td>
         N° Reclamos               </td>
        <td>
            <input id="txteecc0" style="width:350px;"  readonly="readonly" type="text"
                value="<?php echo utf8_encode($row["n_clientes_reclamados"]); ?>" ></td>
    </tr>
    <tr>
        <td>
         Estado               </td>
        <td>
            <input id="txtEstado" style="width:350px;"  readonly="readonly" type="text"
                value="<?php echo utf8_encode($row["estado"]); ?>" ></td>
    </tr>
    <tr>
        <td>
         Nombre Gestor               </td>
        <td>
            <input id="txtNGestor" style="width:350px;"  readonly="readonly" type="text"
                value="<?php echo utf8_encode($row["nom_gestor"]); ?>" ></td>
    </tr>
    <tr>
        <td>
         Tipo De Ruta              </td>
        <td>
            <input id="txtTRuta" style="width:350px;"  readonly="readonly" type="text"
                value="<?php echo utf8_encode($row["tipo_ruta"]); ?>" ></td>
    </tr>
    <tr>
        <td>
         Clientes Afectados               </td>
        <td>
            <input id="txtCAfectado" style="width:350px;"  readonly="readonly" type="text"
                value="<?php echo utf8_encode($row["n_clientes_afectados"]); ?>" ></td>
    </tr>
<tr>
 
</table></center><?
$tipo_cble = $row["tipo_cable"];
}?>
 
<script lenguaje="javascript">
function AprobadoOK(form)
{
document.getElementById('div_es_falla').style.display = 'block';
}
function Rechazo(form)
{
document.getElementById('div_es_falla').style.display = 'none';
}
</script>
<center><h3>Asignación de trabajo</h3>
 
<fieldset width="700px">
    <legend><center>Seleccione: </center></legend>
    <label>
        <input type="radio" name="estado" id="Rechazado" onClick="Rechazo(this.form)" value="Rechazado"> No es Falla
    </label>
<label>
    <input type="radio" name="estado" id="Aprobado" checked value="Aprobado" onClick="AprobadoOK(this.form)"> Es Falla
</label>
</fieldset></div>
  <br/>
    <div id="div_es_falla">
  <table style="width: 50%;" align="center"><tr>
     <td>
        Causa de falla </td>
        <td>  <select id="tipo" name="tipo" class="form-control">
           <option value="Robo">Robo</option>
           <option value="Readecuacion">Readecuacion</option>
           <option value="Transferencia">Transferencia</option>
           <option value="Mantencion">Mantencion</option>
           <option value="Danos por terceros">Daños por terceros</option>
 
        </select></td>
     </tr>
   <tr>
    <td>
        Capacidad Cable </td>
    <td>
        <input id="capacidad" class="form-control" name="capacidad" type="text" /></td><td><i>El valor de capacidad ingresado <b>debe ser numérico</b></i></td>
    </tr>
 
    <tr>
    <td>
        Cuenta 1 </td>
    <td>
        <input id="c1" name="c1" type="text" class="form-control" disabled="disabled" /></td><td>
         Ingresar
        <input type="checkbox" name="chec1"  value="checkbox" onclick="document.getElementById('c1').disabled=!this.checked;">  </td>
    </tr>
 
    <tr>
      <td>
            Cuenta 2 </td>
       <td>
            <input id="c2" name="c2" type="text" class="form-control" disabled="disabled"/></td><td>
                Ingresar
            <input type="checkbox" name="chec2" value="checkbox"  onclick="document.getElementById('c2').disabled=!this.checked;">  </td>
    </tr>
    <tr>
      <td>
            Cuenta 3 </td>
       <td>
            <input id="c3" name="c3" type="text" class="form-control" disabled="disabled"/></td><td>
                 Ingresar
            <input type="checkbox" name="chec3" value="checkbox"  onclick="document.getElementById('c3').disabled=!this.checked;">  </td>
    </tr>
    <tr>
      <td>
            Cuenta 4 </td>
       <td>
            <input id="c4" name="c4" type="text" class="form-control" disabled="disabled"/></td><td>
                 Ingresar
            <input type="checkbox" name="chec4" value="checkbox" onclick="document.getElementById('c4').disabled=!this.checked;">  </td>
    </tr>
    <tr>
      <td>
            Cuenta 5 </td>
       <td>
            <input id="c5" name="c5" type="text"  class="form-control" disabled="disabled"/></br></td><td>
                 Ingresar
            <input type="checkbox" name="chec5" value="checkbox" onclick="document.getElementById('c5').disabled=!this.checked;">  </td>
        </tr>
      </table>
  </div>
<table align="center" style="width: 50%;" >
 
        <tr>
           <td>
                 Par:
           </td>
           <td>
                 <select id="par" name="par" class="form-control">
                        <option value="Par Local">Par Local</option>
                        <option value="Par Externo">Par Externo</option>
                 </select>
           </td>
        </tr>
 
        <tr>
            <td>
                Comentarios: </td>
            <td>
                <textarea rows="4" class="form-control" cols="50" id="obs" name="obs"></textarea></td>
        </tr>
</table>
<br/>
<form  method="$_POST">
    <div align="center">
        <input align="center" name="EnviarInfo" class="btn btn-primary btn-block" type="submit" style="width: 50%"  value="Asignar">
    </div>
</form></center>
 
<?
$link = mysqli_connect("localhost","pcomp","xxx", "xxx");
 
if ($_POST[EnviarInfo])
{
 
    $causa_falla = $_POST['causa_falla'];
    $c1 = $_POST['c1'];
    $c2 = $_POST['c2'];
    $c3 = $_POST['c3'];
    $c4 = $_POST['c4'];
    $c5 = $_POST['c5'];
   $date = date('Y-m-d H:i:s');
   $obs = $_POST['obs'];
   $par = $_POST['par'];
 
 
  if ($_POST['estado'] == 'Rechazado'){
        $sql = "UPDATE 'avisos_auditados' set 'estado'='No es Falla' f_termino='$date' where id_aviso='$id_p'";
 
    if(mysqli_query($link, $sql)){
        echo "<script>alert('Cambios realizados', 'Asignar hd')</script>";
 
    } else{
 
        echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
    }
 
    $yourURL="'ver_aviso_auditado.php?id=$aux'";
    echo ("<script>location.href='$yourURL'</script>");
    echo"<META HTTP-EQUIV='Refresh' CONTENT='0;url=$yourURL'/>";
 
 
 
    }
    else if ($_POST['estado'] == 'Aprobado'){
 
        if ($c1 == "" && $c2 == "" && $c3 == "" && $c4 == "" && $c5 == "" ) {
 
            echo "<script>alert('Debe ingresar una cuenta como minimo', 'Debe ingresar una cuenta')</script>";
 
        }else {
 
            $contadorCuentas = 0;
 
            if ($c1 == "" ) {
 
                $contadorCuentas = $contadorCuentas + 0;
            }else{
 
                $contadorCuentas = $contadorCuentas + 1;
 
            }
 
            if ($c2 == "" ) {
 
                $contadorCuentas = $contadorCuentas + 0;
            }else{
 
                $contadorCuentas = $contadorCuentas + 1;
 
            }
 
            if ($c3 == "" ) {
 
                $contadorCuentas = $contadorCuentas + 0;
            }else{
 
                $contadorCuentas = $contadorCuentas + 1;
 
            }
 
            if ($c4 == "" ) {
 
                $contadorCuentas = $contadorCuentas + 0;
            }else{
 
                $contadorCuentas = $contadorCuentas + 1;
 
            }
 
            if ($c5 == "" ) {
 
                $contadorCuentas = $contadorCuentas + 0;
            }else{
 
                $contadorCuentas = $contadorCuentas + 1;
 
            }
 
			$sql = "UPDATE tabla set estado='Es Falla', f_termino='$date' where id_aviso='$id_p'";
 
            $sql2 = "INSERT INTO avisos (tipo_defecto, direccion, agencia, central, tipo_cable, cable, armario, cuenta1, cuenta2, cuenta3,cuenta4,cuenta5, fecha_ingreso, fecha_revisar_aviso, fecha_respuesta_aviso)
                     VALUES ('$tipo_defecto','$direccion', '$agencia', '$central', '$central','$tipo_cable','$cable','$armario',cuenta1='$c1', cuenta2='$c2',cuenta3='$c3',cuenta4='$c4',cuenta5='$c5','$date','$date','$date')";
 
            if(mysqli_query($link, $sql,$sql2) and mysqli_query($link, $sql2)){
 
                echo "<script>alert('Cambios realizados', 'Asignar hd')</script>";
 
            } else{
 
                echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
            }
 
 
            $yourURL='pagina?id=$aux';
            echo ("<script>location.href='$yourURL'</script>");
            echo"<META HTTP-EQUIV='Refresh' CONTENT='0;url=$yourURL'/>";
 
        }
 
    }
 
 
}
 
?>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
1
Responder
Imágen de perfil de Mauro
Val: 2.761
Oro
Ha aumentado 1 puesto en PHP (en relación al último mes)
Gráfica de PHP

Tengo una pagina con un formulario pero no el boton no esta funcioando

Publicado por Mauro (1037 intervenciones) el 02/10/2018 19:20:39
Para empezar te daré algunas sugerencias generales:

1. No uses el tag corto (<?) de apertura PHP, mejor usa el completo <?php
2. El tag de cierre (?>) final también te conviene dejarlo afuera... el intérprete no lo necesita y a vos te va a complicar al existencia :p
3. El código js incluilo al final (después de todo el html) salvo que algo no funcione (en ese caso ok, dejalo arriba pero no creo que sea la situación tuya), la página cargará más rápido así.
4. De ser posible, separa el PHP del JS
5. No pongas todo el código en un solo archivo. Puede conllevar a errores difíciles de detectar

Ahora, yendo al problema concreto, imagino que el botón al que te refieres es alguno que tenga como id "marca" (Lo digo por el código js que está al comienzo)... no sé si busqué mal o qué (me perdí entre tanto código) pero no encuentro un botón que tenga dicho id... por otro lado, ¿por qué usas el evento "change" en lugar del click?
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