Foros del Web » Programando para Internet » Javascript » Frameworks JS »

redireccionar presionando radiobutton

Estas en el tema de redireccionar presionando radiobutton en el foro de Frameworks JS en Foros del Web. Hola tengo un codigo que valida radiobutton's y me saca un mensaje diferente dependiendo el radiobutton selecionado, pero al tomar esa validacion para que no ...
  #1 (permalink)  
Antiguo 31/10/2010, 21:53
 
Fecha de Ingreso: octubre-2010
Mensajes: 9
Antigüedad: 13 años, 6 meses
Puntos: 0
redireccionar presionando radiobutton

Hola tengo un codigo que valida radiobutton's y me saca un mensaje diferente dependiendo el radiobutton selecionado, pero al tomar esa validacion para que no saque mensajes sino que me redireccione a otro formulario no sirve esta validacion.
Este es el codigo ojala me puedan ayudar.


<script language="JavaScript" src="../js/jquery.js">
</script>

<script>
$(document).ready(function (){
$("#enviar").click( function() {
if($("#Cnatural").attr('checked')) {//aqui es donde quiero redireccionar
top.location.href='Formulario_Empresa.html';
}
if($("#Cempresa").attr("checked")) {//aqui el primer mensaje
alert("Claro");
}
if($("#Cfuncionarios").attr("checked")) {//aqui el segundo mensaje
alert("Como no");
}
});
});

</script>




<table width="282" border="0">
<tr>
<td height="51" colspan="3"><label></label>
<div align="center">Elija el tipo de Usuario a crear </div></td>
</tr>
<tr>
<td width="31" height="34">&nbsp;</td>
<td><label></label>
<label></label></td>
<td>


<form id="form12" method="post" action="" >
<label>
<input name="radiobutton" id ="Cnatural" type="radio" value="radio1" />
Cliente Natural</label>
<a href="Formulario_Usuario.html"></a>
<br>


<label>
<input name="radiobutton" id ="Cempresa" type="radio" value="radio2" />
Empresa</label>
<a href="Formulario_Empresas.html"></a>
<br>

<label>
<input name="radiobutton" id ="Cfuncionarios" type="radio" value="radio3" />
Funcionario</label>
</td>
</tr>
<tr>
<td height="34">&nbsp;</td>
<td width="6">&nbsp;</td>
<td width="197"><input type="submit" name="btn1" value="Aceptar" id="enviar">
<input type="submit" name="Submit2" value="Cancelar"/></td>
</tr>
</form>
</table>

Última edición por hicetnunc86; 01/11/2010 a las 13:57
  #2 (permalink)  
Antiguo 02/11/2010, 12:57
 
Fecha de Ingreso: octubre-2010
Mensajes: 83
Antigüedad: 13 años, 6 meses
Puntos: 4
Respuesta: redireccionar presionando radiobutton

Que es top en esta linea?

Código:
top.location.href='Formulario_Empresa.html';
  #3 (permalink)  
Antiguo 02/11/2010, 19:07
Avatar de chicohot20  
Fecha de Ingreso: mayo-2009
Mensajes: 388
Antigüedad: 15 años
Puntos: 43
Respuesta: redireccionar presionando radiobutton

Tu boton es de tipo submit, tienes que cancelar el evento con un return false;
$("#enviar").click(function() {
if($("#Cnatural").attr("checked")) {
location.href="index.html";
}
if($("#Cempresa").attr("checked")) {
alert("Claro");
}
if($("#Cfuncionarios").attr("checked")) {
alert("Como no");
}
return false;
});
  #4 (permalink)  
Antiguo 03/11/2010, 13:08
 
Fecha de Ingreso: octubre-2010
Mensajes: 9
Antigüedad: 13 años, 6 meses
Puntos: 0
Respuesta: redireccionar presionando radiobutton

Hola chicohot,
el return false redirecciona pero no con ajax, es decir, no redirecciona sobre la misma pagina.
igualmente gracias.
  #5 (permalink)  
Antiguo 03/11/2010, 13:11
 
Fecha de Ingreso: octubre-2010
Mensajes: 9
Antigüedad: 13 años, 6 meses
Puntos: 0
Respuesta: redireccionar presionando radiobutton

snhor ese codigo sirve para redireccionar hacia el formulario que deseo ver.
  #6 (permalink)  
Antiguo 05/11/2010, 20:04
 
Fecha de Ingreso: octubre-2010
Mensajes: 9
Antigüedad: 13 años, 6 meses
Puntos: 0
Respuesta: redireccionar presionando radiobutton

a los que les interese les dejo la solución que hallé.

codigo HTML:
  #7 (permalink)  
Antiguo 05/11/2010, 20:05
 
Fecha de Ingreso: octubre-2010
Mensajes: 9
Antigüedad: 13 años, 6 meses
Puntos: 0
Respuesta: redireccionar presionando radiobutton

Cita:
Iniciado por hicetnunc86 Ver Mensaje
a los que les interese les dejo la solución que hallé.

codigo HTML:

htmls
  #8 (permalink)  
Antiguo 05/11/2010, 20:10
 
Fecha de Ingreso: octubre-2010
Mensajes: 9
Antigüedad: 13 años, 6 meses
Puntos: 0
Respuesta: redireccionar presionando radiobutton

<body>
<script language="JavaScript" src="../js/jquery.js">
</script>
<script>
$(document).ready(function (){
$("#enviar").click( function() {
$("#formulario").hide();
if($("#Cnatural").attr('checked')) {
var opc = "natu";
}
if($("#Cempresa").attr("checked")) {
var opc = "empr";
}
if($("#Cfuncionarios").attr("checked")) {
var opc = "func";
}
$.ajax({
type: 'POST',
url: 'html2/prueba.php',
data: 'opc='+opc,
success: function(datos){
$("#resu").html(datos);
}
});




});
});
</script>
<div id="formulario">
<form id="form12" method="post" action="" >
<label>
<input name="radiobutton" id ="Cnatural" type="radio" value="radio1" />
Cliente Natural</label>
<a href="Formulario_Usuario.html"></a>
<br>

<label>
<input name="radiobutton" id ="Cempresa" type="radio" value="radio2" />
Empresa</label>
<a href="Formulario_Empresas.html"></a>
<br>
<tr>
<td>
<label>
<input name="radiobutton" id ="Cfuncionarios" type="radio" value="radio3" />
Funcionario</label>
</td>
</tr>
<tr>
<td height="34">&nbsp;</td>
<td width="6">&nbsp;</td>
<td width="197"><input type="button" name="btn1" value="Aceptar" id="enviar">
<input type="submit" name="Submit2" value="Cancelar"/></td>
</tr>
</form>
</div>
<div id ="resu">fdgdf
</div>
</body>
</html>
  #9 (permalink)  
Antiguo 05/11/2010, 20:16
 
Fecha de Ingreso: octubre-2010
Mensajes: 9
Antigüedad: 13 años, 6 meses
Puntos: 0
Respuesta: redireccionar presionando radiobutton

<?php
$opc = $_REQUEST['opc'];
$opc2 = $_REQUEST['opc2'];
$opc3 = $_REQUEST['opc3'];
$empre= "empr";
$natur= "natu";
$funci= "func";
if ($opc==$empre)
{
Header("location: Formulario_Empresa.html");
}
if ($opc==$natur)
{
Header("location: Formulario_Usuario.html");
}
if ($opc==$funci)
{
Header("location: Formulario_Funcionarios.html");
}
?>
  #10 (permalink)  
Antiguo 05/11/2010, 20:18
 
Fecha de Ingreso: octubre-2010
Mensajes: 9
Antigüedad: 13 años, 6 meses
Puntos: 0
Respuesta: redireccionar presionando radiobutton

<?php
$opc = $_REQUEST['opc'];
$opc2 = $_REQUEST['opc2'];
$opc3 = $_REQUEST['opc3'];
$empre= "empr";
$natur= "natu";
$funci= "func";
if ($opc==$empre)
{
Header("location: Formulario_Empresa.html");
}
if ($opc==$natur)
{
Header("location: Formulario_Usuario.html");
}
if ($opc==$funci)
{
Header("location: Formulario_Funcionarios.html");
}
?>



Última edición por hicetnunc86; 05/11/2010 a las 20:42
  #11 (permalink)  
Antiguo 05/11/2010, 20:45
 
Fecha de Ingreso: octubre-2010
Mensajes: 9
Antigüedad: 13 años, 6 meses
Puntos: 0
Respuesta: redireccionar presionando radiobutton

Cita:
Iniciado por hicetnunc86 Ver Mensaje
htmls
Cita:
Iniciado por hicetnunc86 Ver Mensaje
a los que les interese les dejo la solución que hallé.

codigo HTML:
<body>
<script language="JavaScript" src="../js/jquery.js">
</script>

<script>
$(document).ready(function (){
$("#enviar").click( function() { $("#formulario").hide();
if($("#Cnatural").attr('checked')) {
var opc = "natu";
}
if($("#Cempresa").attr("checked")) {
var opc = "empr";
}
if($("#Cfuncionarios").attr("checked")) {
var opc = "func";
}

$.ajax({
type: 'POST',
url: 'html2/prueba.php',
data: 'opc='+opc,
success: function(datos){
$("#resu").html(datos);
}
});




});
});
</script>
<div id="formulario">
<form id="form12" method="post" action="" >
<label>
<input name="radiobutton" id ="Cnatural" type="radio" value="radio1" />
Cliente Natural</label>
<a href="Formulario_Usuario.html"></a>
<br>


<label>
<input name="radiobutton" id ="Cempresa" type="radio" value="radio2" />
Empresa</label>
<a href="Formulario_Empresas.html"></a>
<br>
<tr>
<td>
<label>
<input name="radiobutton" id ="Cfuncionarios" type="radio" value="radio3" />
Funcionario</label>
</td>
</tr>
<tr>
<td height="34">&nbsp;</td>
<td width="6">&nbsp;</td>
<td width="197"><input type="button" name="btn1" value="Aceptar" id="enviar">
<input type="submit" name="Submit2" value="Cancelar"/></td>
</tr>
</form>
</div>
<div id ="resu">fdgdf
</div>
</body>
</html>

Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:08.