PHP - activar un button, select , date y fecha con checkbox

 
Vista:
sin imagen de perfil

activar un button, select , date y fecha con checkbox

Publicado por andres (63 intervenciones) el 18/03/2014 17:23:48
Hola comunidad pues vaya tengo la siguiente duda tengo el siguiente codigo pero no me activa nada ya lo probe con una alert() y efectivamente entra a la funcion de javascript pero nada no los activa que puede estar pasando gracias por la colaboracion

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
<?php
	require('php_lib/login.class.php');
	if(!isset($_SESSION))
  {
     session_start();
  }
	$licencia1=$_SESSION['LICENCIA'];
	require_once('php/prospecto_modelo.php');
	$prospecto1 = new Prospecto();
	$listado = $prospecto1->listaProspecto($licencia1);
 
 
?>
<html>
	<head>
		<title>Listado de Prospectos</title>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1' />
        <link rel="stylesheet" type="text/css" href="estiloP.css" />
        <script language="javascript" type="text/javascript" src="jquery.js"> </script>
	    <script type="text/javascript" language="javascript" src="funcionesJquery.js"></script>
        <script language="javascript">
		function activar(){
 
             if (tipos.disabled == false && fecha.disabled == false && hora.disabled == false && guardarComen.disabled == false  ){
                tipos.disabled = true;
                fecha.disabled = true;
                hora.disabled = true;
                guardarComen.disabled = true;
            }else{
                tipos.disabled = false;
                fecha.disabled = false;
                hora.disabled = false;
                guardarComen.disabled = false;
            }
        }
 
 
	</script>
 
	</head>
 
    <body>
 
 
            <?php $Ncabezera=0; $ps=": " ?>
			<?php foreach($listado as $fila){
 
             $idComen= $fila['id'];
			 $Ncabezera= $Ncabezera + 1;
             ?>
			<form method="post">
			<div style="float: left; border-bottom: 1px dotted #444; border-width: 2px; margin-top: 10px;">
 
                 <div style="float: left; width: 100%; margin-bottom: 10px; ">
 
                    <div style="float: left; width: 60%; margin-top: 5px;">
 
                        <div style="float: left; width: 100%;">
 
                            <div style="float: left; width: 45%;">
 
                              <div  style="float:left; width: 35%; height: auto;">
              				      <ul style="font-family:sans-serif; font-size:10px; list-style:none; margin: 0; padding: 0;" align="left">
                                    <li><?php echo $Ncabezera;  ?></li>
                                    <li> <IMG SRC="<?php  echo $fila['campo24']; ?>" width=70% height=70px; /> </li>
                                    <li>valor</li>
                                  </ul>
 
            			      </div>
 
                              <div  style="float:left; width: 65%; height: auto;">
 
                                  <ul style="font-family:sans-serif; font-size:12px; list-style:none; margin: 0; padding: 0;" align="left">
            				        <div style="margin-left: 10px;">
            					       <li><b><?php echo $fila['nombres'] ?></b> </li>
 
            					       <li><?php echo $fila['campo3'] ?> </li>
 
                					   <li><IMG SRC="images/tel.png"/> <?php echo $fila['campo5'] ?> </li>
 
                					   <li><IMG SRC="images/cel.png"> <?php echo $fila['campo6'] ?> </li>
 
                					   <li><IMG SRC="images/dir.png"> <?php echo $fila['campo4'] ?> </li>
 
                					   <li><IMG SRC="images/mail.png"> <?php echo $fila['campo7'] ?> </li>
            				        </div>
                                  </ul>
 
            			      </div>
 
                            </div>
 
                            <div style="float: left; width: 50%;">
 
                                <div style="float: left; width: 100%;">
 
                                    <div style="float: left;" >
                        				<IMG SRC="images/referido.png" class="Adias" title="<?php echo "Referido"; ?>"/>
                        			</div>
 
                        			<div style="float: right; ">
                        				<IMG SRC="images/recordatorio.png" class="Arecordatorio" title="<?php echo "Recordatorio"; ?>"/>
                        			</div>
 
                                </div>
 
                                <div style="float: left; width: 100%;">
                                    <iframe frameborder="0" scrolling="no" marginheight="0" marginwidth="0" width="100%" src="https://maps.google.es/?ie=UTF8&amp;ll=3.444883,-76.437378&amp;spn=0.834815,1.352692&amp;t=m&amp;z=10&amp;output=embed"></iframe><br />
            		            </div>
 
                            </div>
 
                        </div>
 
                        <form method="post">
                        <div style="float: left; width: 95%;">
 
                            <label>Seguimiento</label>
 
                            <?php
                            $comentarios= new Prospecto();
                            $lista = $comentarios->comentarios($idComen);
                            ?>
                            <?php foreach($lista as $campo) { ?>
                                <div style="border:1px solid #000000;   background-color: #edeff4; margin-top: 2px;" > <?php print_r($_SESSION['NOMBRE']);echo $ps; echo $campo['comentario']; ?> </div>
                            <?php } ?>
                            <div style="border:1px solid #000000;   background-color: #edeff4; margin-top: 2px;">
                                <input type="text" id="nuevoComentario" placeholder="Escriba aqui un nuevo comentario" style="width: 100%;" />
                                <li style="list-style: none; font-size: 11px; ">
                                    <label>Recordatorio?</label>
                                    <input type="checkbox" id="activaRecordatorio" name="recordatorio" value="1" onchange="javascript:activar()" /> &nbsp;
                                    <label>Tipos: </label>
                                    <select id="tipos" disabled="disabled"  >
                                        <option value="1">Llamada</option>
                                        <option value="2">Visita</option>
                                        <option value="3">Confirmacion</option>
                                    </select> &nbsp;
                                    <label> Fecha</label>
                                    <input type="date" name="fecha" required="required" value="" disabled="disabled" id="fecha" />&nbsp;
                                    <label>Hora</label>
                                    <input type="time" name="hora" required="required" value="" disabled="disabled" id="hora" /> &nbsp;
                                    <input type="button" value="Guardar" id="guardarComen" disabled="disabled"  />
                                </li>
 
                            </div>
                        </div>
                        </form>
                    </div>
 
                    <div style="float: left; width: 35%;">
 
                       <div style="float: left; width: 100%; padding: 10px 0 0 10px;">
                                <div style="float: left; width: 100%;">
                    				cuadro 1
                    			</div>
 
                    			<div style="float: left; width: 100%;">
                    				cuadro 2
                    			</div>
                        </div>
 
                    </div>
 
                </div>
 
           </div>
		 </form>
		  <?php } ?>
	</body>
</html>
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
Imágen de perfil de xve
Val: 3.943
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

activar un button, select , date y fecha con checkbox

Publicado por xve (6935 intervenciones) el 18/03/2014 18:53:25
Hola Andres, he visto tu función activar() (supongo que haces referencia a esta funcion...), y veo que las variables que utilizas, ya sea tipos, fecha, hora, ... no están definidas en el código... es decir, no existen, no?

Que es la variable tipos?? si hace referencia al select, tendría que definir-lo algo así:
1
var tipos=document.getElementById("tipos").value;

Coméntanos, ok?
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

activar un button, select , date y fecha con checkbox

Publicado por andres (63 intervenciones) el 18/03/2014 19:03:30
pero mira yo en otra funcion en otra pagina las uso asi mira y me funcionan (si es la funcion activar)

1
2
3
4
5
6
7
8
9
10
11
<script language="javascript">
		function checar(){
    if (registrarce.disabled == false){
        registrarce.disabled = true;
    }else{
        registrarce.disabled = false;
    }
}
 
 
	</script>

y los inputs

1
2
<input type="checkbox" id="aceptaCondiciones" name="aceptaTC" value='1' onchange="javascript:checar()" /> <label><a href="#">Acepta terminos y codiciones de uso de este software </a></label>
<center><input disabled="disabled"  type="button" id="registrarce" value="Registrar" name="enviar" onclick=" return confirm('Bienvenido ya estas registrado')" /></center>
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 xve
Val: 3.943
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

activar un button, select , date y fecha con checkbox

Publicado por xve (6935 intervenciones) el 18/03/2014 22:39:06
Hola Andres, este código no funciona por si solo... lo que puede ser, que haya en algún lugar donde se definan los contenido de estas variables.
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

activar un button, select , date y fecha con checkbox

Publicado por andres (63 intervenciones) el 18/03/2014 19:15:08
Ya lo probe con tu linea de codigo y tampoco funciona entra a la funcion pero no realiza nada
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 xve
Val: 3.943
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

activar un button, select , date y fecha con checkbox

Publicado por xve (6935 intervenciones) el 18/03/2014 22:38:23
Para que te funcione, tienes que definir todas las variables que utilizas, no solamente la tipos.

Aunque como te lo he puesto, es para cojer su valor, no para ver si esta enabled o disabled... para ello prueba así:
1
var tipos=document.getElementById("tipos");
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

activar un button, select , date y fecha con checkbox

Publicado por andres (63 intervenciones) el 18/03/2014 23:33:15
No tampoco hay ni siquiera entra a la funcion no se que mas hacerle a eso
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 xve
Val: 3.943
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

activar un button, select , date y fecha con checkbox

Publicado por xve (6935 intervenciones) el 19/03/2014 08:15:56
Hola Andres, no se como lo has probado, ya que no muestras el código... pero simplemente añade esto dentro de la función activar(), al inicio:
1
2
3
4
var tipos=document.getElementById("tipos");
            var hora=document.getElementById("hora");
            var fecha=document.getElementById("fecha");
            var guardarComen=document.getElementById("guardarComen");

Yo lo he probado y me funciona correctamente.

Coméntanos, ok?
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

activar un button, select , date y fecha con checkbox

Publicado por andres (63 intervenciones) el 19/03/2014 16:00:27
nada mira el codigo que tengo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<script language="javascript">
 
	       function activar(){
            var tipos=document.getElementById("tipos");
            var hora=document.getElementById("hora");
            var fecha=document.getElementById("fecha");
            var guardarComen=document.getElementById("guardarComen");
 
             if (tipos.disabled == false && fecha.disabled == false && hora.disabled == false && guardarComen.disabled == false  ){
                alert('pasa');
                tipos.disabled = true;
                fecha.disabled = true;
                hora.disabled = true;
                guardarComen.disabled = true;
            }else{
                alert('malo');
                tipos.disabled = false;
                fecha.disabled = false;
                hora.disabled = false;
                guardarComen.disabled = false;
            }
        }
 
    	</script>

y el de html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<form method="post">
 <div style="border:1px solid #000000;   background-color: #edeff4; margin-top: 2px;">
                                <input type="text" id="nuevoComentario" placeholder="Escriba aqui un nuevo comentario" style="width: 100%;" onkeydown="guardaComen()" />
                                <li style="list-style: none; font-size: 11px; ">
                                    <label>Recordatorio?</label>
                                    <input type="checkbox" id="recordatorio" name="recordatorio" value='1' onchange="javascript:activar()" />
                                </li>
                                <li style="list-style: none; font-size: 11px; "  >
                                    &nbsp;
                                    <label>Tipos: </label>
                                    <select id="tipos" disabled="disabled"  >
                                        <option value="1">Llamada</option>
                                        <option value="2">Visita</option>
                                        <option value="3">Confirmacion</option>
                                    </select> &nbsp;
                                    <label> Fecha</label>
                                    <input type="date" name="fecha"  value="" disabled="disabled" id="fecha" />&nbsp;
                                    <label>Hora</label>
                                    <input type="time" name="hora" value=""  id="hora" disabled="false" /> &nbsp;
                                    <input type="button" value="Guardar" id="guardarComen" disabled="disabled"  />
                                </li>
                             </div>
</form>
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 xve
Val: 3.943
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

activar un button, select , date y fecha con checkbox

Publicado por xve (6935 intervenciones) el 19/03/2014 17:14:55
Hola Andres, este es el código que ho he utilizado... lo copias en un archivo html y lo pruebas, a mi me funciona en chrome y firefox.
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
<html>
    <head>
        <title>Listado de Prospectos</title>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1' />
        <link rel="stylesheet" type="text/css" href="estiloP.css" />
        <script language="javascript" type="text/javascript" src="jquery.js"> </script>
        <script type="text/javascript" language="javascript" src="funcionesJquery.js"></script>
        <script language="javascript">
        function activar(){
            var tipos=document.getElementById("tipos");
            var hora=document.getElementById("hora");
            var fecha=document.getElementById("fecha");
            var guardarComen=document.getElementById("guardarComen");
 
             if (tipos.disabled == false && fecha.disabled == false && hora.disabled == false && guardarComen.disabled == false  ){
                tipos.disabled = true;
                fecha.disabled = true;
                hora.disabled = true;
                guardarComen.disabled = true;
            }else{
                tipos.disabled = false;
                fecha.disabled = false;
                hora.disabled = false;
                guardarComen.disabled = false;
            }
        }
 
 
    </script>
 
    </head>
 
    <body>
 
 
            <form method="post">
            <div style="float: left; border-bottom: 1px dotted #444; border-width: 2px; margin-top: 10px;">
 
                 <div style="float: left; width: 100%; margin-bottom: 10px; ">
 
                    <div style="float: left; width: 60%; margin-top: 5px;">
 
                        <div style="float: left; width: 100%;">
 
                            <div style="float: left; width: 45%;">
 
                              <div  style="float:left; width: 35%; height: auto;">
                                  <ul style="font-family:sans-serif; font-size:10px; list-style:none; margin: 0; padding: 0;" align="left">
                                    <li><?php echo $Ncabezera;  ?></li>
                                    <li> <IMG SRC="<?php  echo $fila['campo24']; ?>" width=70% height=70px; /> </li>
                                    <li>valor</li>
                                  </ul>
 
                              </div>
 
                              <div  style="float:left; width: 65%; height: auto;">
 
                                  <ul style="font-family:sans-serif; font-size:12px; list-style:none; margin: 0; padding: 0;" align="left">
                                    <div style="margin-left: 10px;">
                                       <li><b><?php echo $fila['nombres'] ?></b> </li>
 
                                       <li><?php echo $fila['campo3'] ?> </li>
 
                                       <li><IMG SRC="images/tel.png"/> <?php echo $fila['campo5'] ?> </li>
 
                                       <li><IMG SRC="images/cel.png"> <?php echo $fila['campo6'] ?> </li>
 
                                       <li><IMG SRC="images/dir.png"> <?php echo $fila['campo4'] ?> </li>
 
                                       <li><IMG SRC="images/mail.png"> <?php echo $fila['campo7'] ?> </li>
                                    </div>
                                  </ul>
 
                              </div>
 
                            </div>
 
                            <div style="float: left; width: 50%;">
 
                                <div style="float: left; width: 100%;">
 
                                    <div style="float: left;" >
                                        <IMG SRC="images/referido.png" class="Adias" title="<?php echo "Referido"; ?>"/>
                                    </div>
 
                                    <div style="float: right; ">
                                        <IMG SRC="images/recordatorio.png" class="Arecordatorio" title="<?php echo "Recordatorio"; ?>"/>
                                    </div>
 
                                </div>
 
                                <div style="float: left; width: 100%;">
                                    <iframe frameborder="0" scrolling="no" marginheight="0" marginwidth="0" width="100%" src="https://maps.google.es/?ie=UTF8&amp;ll=3.444883,-76.437378&amp;spn=0.834815,1.352692&amp;t=m&amp;z=10&amp;output=embed"></iframe><br />
                                </div>
 
                            </div>
 
                        </div>
 
                        <form method="post">
                        <div style="float: left; width: 95%;">
 
                            <label>Seguimiento</label>
 
                            <div style="border:1px solid #000000;   background-color: #edeff4; margin-top: 2px;">
                                <input type="text" id="nuevoComentario" placeholder="Escriba aqui un nuevo comentario" style="width: 100%;" />
                                <li style="list-style: none; font-size: 11px; ">
                                    <label>Recordatorio?</label>
                                    <input type="checkbox" id="activaRecordatorio" name="recordatorio" value="1" onchange="javascript:activar()" /> &nbsp;
                                    <label>Tipos: </label>
                                    <select id="tipos" disabled="disabled"  >
                                        <option value="1">Llamada</option>
                                        <option value="2">Visita</option>
                                        <option value="3">Confirmacion</option>
                                    </select> &nbsp;
                                    <label> Fecha</label>
                                    <input type="date" name="fecha" required="required" value="" disabled="disabled" id="fecha" />&nbsp;
                                    <label>Hora</label>
                                    <input type="time" name="hora" required="required" value="" disabled="disabled" id="hora" /> &nbsp;
                                    <input type="button" value="Guardar" id="guardarComen" disabled="disabled"  />
                                </li>
 
                            </div>
                        </div>
                        </form>
                    </div>
 
                    <div style="float: left; width: 35%;">
 
                       <div style="float: left; width: 100%; padding: 10px 0 0 10px;">
                                <div style="float: left; width: 100%;">
                                    cuadro 1
                                </div>
 
                                <div style="float: left; width: 100%;">
                                    cuadro 2
                                </div>
                        </div>
 
                    </div>
 
                </div>
 
           </div>
         </form>
    </body>
</html>
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
sin imagen de perfil

activar un button, select , date y fecha con checkbox

Publicado por andres (63 intervenciones) el 19/03/2014 17:38:58
xve hermano muchas pero muchisimas gracias me salvo de una ya vi cual era el horror que tenia muchas gracias mi hermano
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

activar un button, select , date y fecha con checkbox

Publicado por andres (63 intervenciones) el 19/03/2014 17:48:48
encontre un error siempre me activa el primero nunca los demas
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