PHP - limpiar los campos cuando hay una consulta en los mismos

 
Vista:
Imágen de perfil de Hfr
Val: 36
Ha disminuido su posición en 52 puestos en PHP (en relación al último mes)
Gráfica de PHP

limpiar los campos cuando hay una consulta en los mismos

Publicado por Hfr (93 intervenciones) el 24/02/2016 20:09:16
hola chicos , tengo un formulario al cual le cargo datos de la base datos a los campos, esto lo hago con php,
cuando cargo el formulario todos los campos están des habilitados,
yo realice varios eventos en js para habilitar los campos modificar los datos y posteriormente actualizar el registro.
uno de los eventos me limpia tres campos al seleccionar un radio btn pero estos no se limpian porque se carga la consulta ,
alguein me puede dr una manito...

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
<div class="fila">
  <?PHP  $tsn =mysqli_query ($xCon, "   SELECT  `si_no` FROM `existencia` WHERE `cod_id_nnja`='$datocombo' and `cod_nemo`='cesmg'  " );   ?>
        <span class="etiqueta"><label for="apellido">REMISIONES A <br> MEDICINA /EXÁMENES ESPECIALIZADOS</label></span><br>
       &nbsp;&nbsp; si &nbsp;&nbsp;<input name="actu_rad_sn"required   type="radio"value="1"  onClick="return obligatoriosx(this.form);" disabled <?php while ($column=mysqli_fetch_array($tsn)) { if ($column['si_no']==1){echo "checked";} ?>    />&nbsp;&nbsp;No &nbsp;&nbsp;<input     required name="actu_rad_sn" type="radio"  disabled value="0" <?php if ($column['si_no']=0)  { echo "checked";}}?>  onClick="return noobligatorio(this.form);"/>
</div>
 
 
 
 
<div class="fila">
  <?PHP  $tsn =mysqli_query ($xCon, "   SELECT  `si_no` FROM `existencia` WHERE `cod_id_nnja`='$datocombo' and `cod_nemo`='cesmg'  " );   ?>
        <span class="etiqueta"><label for="apellido">REMISIONES A <br> MEDICINA /EXÁMENES ESPECIALIZADOS</label></span><br>
       &nbsp;&nbsp; si &nbsp;&nbsp;<input name="actu_rad_sn"required   type="radio"value="1"  onClick="return obligatoriosx(this.form);" disabled <?php while ($column=mysqli_fetch_array($tsn)) { if ($column['si_no']==1){echo "checked";} ?>    />&nbsp;&nbsp;No &nbsp;&nbsp;<input     required name="actu_rad_sn" type="radio"  disabled value="0" <?php if ($column['si_no']=0)  { echo "checked";}}?>  onClick="return noobligatorio(this.form);"/>
</div>
 
 
 
 
 
   <?PHP  $cul =mysqli_query ($xCon, " SELECT `cual`  FROM `existencia` WHERE `cod_id_nnja`='$datocombo' and `cod_nemo`='cesmg'  " );   ?>
 
        <span class="etiqueta"><label for="mensaje">CUÁL <br></label></span><br>
         <span class="form-el"><input  name="actu_CUAL" disabled type="text"    disabled value="<?php if ($cul){while ($colum=mysqli_fetch_array($cul)){ echo  utf8_encode($colum['cual']); }}?>">
		</span>
 
 
 
	  <div class="fila">
	   <?PHP  $PF =mysqli_query ($xCon, " SELECT  `nom_profecional`  FROM `existencia` WHERE `cod_id_nnja`='$datocombo' and `cod_nemo`='cesmg'  " );   ?>
 
     <span class="etiqueta"><label for="username">NOMBRE DEL PROFESIONAL</label></span><br>
      <span class="form-el"><input  name="act_nom_pro"  disabled type="text" VALUE="<?php if ($PF){while ($colum=mysqli_fetch_array($PF)){ echo  utf8_encode($colum['nom_profecional']); }}?>"></span>
 
	     </div>
 
		 <?PHP  $nex =mysqli_query ($xCon, " SELEC `fec_prox_control` FROM `existencia` WHERE `cod_id_nnja`='$datocombo' and `cod_nemo`='cesmg'  " );   ?>
 
        <span class="etiqueta"><label for="nombre">PRÓXIMO CONTROL   </label></span><br>
		<input  name="act_fech_next"    type="date" disabled  value="<?php if ($nex){while ($colum=mysqli_fetch_array($nex)){ echo  $colum['fec_prox_control']; }}?>">
 
		</div>
 
 
 
 <div class="fila">
        <span class="etiqueta"><label for="nombre">  </label></span>
        <span class="form-el"> <input name="btn_guardar"  class="button white" type="submit" value="ENVIAR  DATOS"	    /></span>
   </div></center>
 
 
    <div class="fila">
        <span class="etiqueta"><label for="nombre">  </label></span>
<input name="nuevo"   class="button white" type="submit" value="nuevo"  onClick="return habilita_actulizar(this.form);" >
   </div>
 
    <div class="fila">
        <span class="etiqueta"><label for="nombre">  </label></span>
         <input name="cancelar"  class="button white" type="submit" value="cancelar"  disabled onClick="return action_cancel(this.form);" >
 
</div>



eventos..

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
<script languaje="javascript">
function obligatoriosx(form)
{
	form.actu_CUAL.readOnly=false;
	form.actu_CUAL.required=true;
	form.act_nom_pro.readOnly=false;
	form.act_nom_pro.required=true;
	form.act_fech_next.readOnly=false;
	form.act_fech_next.required=true;
}
function noobligatorio(form)
{
	from.actu_CUAL.readOnly=true;
	form.actu_CUAL.required=false;
	form.actu_CUAL.value='';
 
	form.act_nom_pro.readOnly=true;
	form.act_nom_pro.required=false;
	form.act_nom_pro.value='';
 
	form.act_fech_next.readOnly=true;
	form.act_fech_next.required=false;
	form.act_fech_next.value='';
 
}
 
 
 
 
 function habilita_actulizar(form){
 
	if (form.actu_fecha.disabled == true)
	{
		form.actu_fecha.disabled = false ;
		form.actu_radio[0].disabled = false;
		form.actu_radio[1].disabled = false;
		form.actu_diag.disabled = false;
		form.acutu_plan_ac.disabled = false;
		form.actu_rad_sn[0].disabled = false;
		form.actu_rad_sn[1].disabled = false;
		form.actu_CUAL.disabled = false;
		form.act_nom_pro.disabled = false;
		form.NNJA_ACT.disabled = false;
		form.act_fech_next.disabled = false;
 
		form.nuevo.disabled = true;
		form.cancelar.disabled=false;
 
 
		alert('los campos se han desahabilitado para actualizar el registro.');
		return false;
 
 
	}
}
 
 function action_cancel(form)
 {
	 if (form.NNJA_ACT.disabled == false )
	 {
		 form.NNJA_ACT.disabled=true;
		 form.actu_rad_sn[0].disabled=true;
		 form.actu_rad_sn[1].disabled=true;
		 form.actu_diag.disabled=true;
		 form.actu_fecha.disabled=true;
		 form.acutu_plan_ac.disabled=true;
		 form.actu_CUAL.disabled=true;
		 form.act_nom_pro.disabled=true;
		 form.act_fech_next.disabled=true;
		 form.actu_radio[0].disabled=true;
		 form.actu_radio[1].disabled=true;
 
		 form.cancelar.disabled=true;
		 form.nuevo.disabled=false;
		return false;
	 }
 
}
 
function verificacontrol(form)
{
if ( form.actu_rad_sn[0].checked == true  && form.act_fech_next.required == true )
{
	if(form.act_fech_next.value.length <10)
	{
		alert('El campo está incompleto. O no has ingresado una fecha valida');
		form.act_fech_next.value='';
		form.act_fech_next.focus();
		return false;
	}
}
	if  (form.rad_sn[1].checked == true)
	{
		if (form.act_fech_next.readOnly == true && form.act_fech_next.value != '')
			{
				alert('el campo no puede tener datos');
				form.act_fech_next.value='';
				return false;
			}
	}
}
 
 
 
</script>
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