JavaScript - desabilitar un select con otro select en jquery

 
Vista:
Imágen de perfil de IVAN

desabilitar un select con otro select en jquery

Publicado por IVAN (3 intervenciones) el 26/10/2013 18:10:21
ESTO FUNCIONA MUY BIEN PERO NECESITO QUE FUNCIONE CON JQUERY... 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
<head>
	<meta charset="utf-8">
	<meta title="habilitar, deshabilitar combos según selección en otro combo">
 
	<script>
		function habilitar(value)
		{
			if(value=="1" || value==true)
			{
				// habilitamos
				document.getElementById("segundo").disabled=false;
			}else if(value=="2" || value==false){
				// deshabilitamos
				document.getElementById("segundo").disabled=true;
			}
		}
	</script>
</head>
 
<body>
<form>
	<h1>habilitar, deshabilitar combos según selección en otro combo</h1>
	<div>
		<select name="primero" id="primero" onchange="habilitar(this.value);">
			<option value='0'>selecciona</option>
			<option value='1'>habilitar el segundo</option>
			<option value='2'>deshabilitar el segundo</option>
		</select>
	</div>
	<div>
		<select name="segundo" id="segundo">
			<option value='1'>seleccion 1</option>
			<option value='2'>seleccion 2</option>
		</select>
	</div>
</form>
</body>
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.162
Oro
Ha mantenido su posición en JavaScript (en relación al último mes)
Gráfica de JavaScript

desabilitar un select con otro select en jquery

Publicado por xve (2100 intervenciones) el 27/10/2013 17:37:11
tienes que reemplazar:
1
document.getElementById("segundo").disabled=false;
por:
1
$("#segundo").show();

y:
1
document.getElementById("segundo").disabled=true;
por:
1
$("#segundo").hide();

saldos
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 bit

desabilitar un select con otro select en jquery

Publicado por bit (3 intervenciones) el 06/11/2013 16:03:54
SOLO QUIERO DES HABILITAR NO QUE DESAPAREZCA... HELP
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.162
Oro
Ha mantenido su posición en JavaScript (en relación al último mes)
Gráfica de JavaScript

desabilitar un select con otro select en jquery

Publicado por xve (2100 intervenciones) el 06/11/2013 21:28:01
Huy, mil perdones...
para deshabilitar que no se pueda seleccionar seria algo así:

1
$("#segundo").prop('disabled', true);

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
Imágen de perfil de bit

desabilitar un select con otro select en jquery

Publicado por bit (3 intervenciones) el 07/11/2013 13:07:06
EXCELENTE! FUNCIONA PERFECTAMENTE GRANDE..! 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