04/04/2012, 09:21
|
| | Fecha de Ingreso: marzo-2011
Mensajes: 13
Antigüedad: 13 años, 9 meses Puntos: 0 | |
Respuesta: Dejar seleccionado el radio boton despues de actualizar la pagina Hola.
He realizado un ejemplo en JavaScript usando cookie espero haber ayudado.
Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript">
window.onload = function(){
var radioId = getCookie("radio_checked");
if(radioId=='undefined'){
document.getElementById(radioId).checked =true;
}
guardar_estado("RadioGroup1");
}
function guardar_estado(name){
var el =document.getElementsByName(name);
for(var i =0; i < el.length;i++){
el[i].addEventListener("change",function(){
setCookie("radio_checked",this.id,365)
},false);
}
}
function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}
function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
x=x.replace(/^\s+|\s+$/g,"");
if (x==c_name)
{
return unescape(y);
}
}
}
</script>
</head>
<body>
<p>
<label>
<input type="radio" name="RadioGroup1" value="iphone" id="RadioGroup1_0" />
iphone</label>
<br />
<label>
<input type="radio" name="RadioGroup1" value="android" id="RadioGroup1_1" />
android</label>
<br />
<label>
<input type="radio" name="RadioGroup1" value="blackberry" id="RadioGroup1_2" />
blackberry</label>
<br />
</p>
</body>
</html>
|