Ver Mensaje Individual
  #2 (permalink)  
Antiguo 19/11/2007, 17:20
Avatar de derkenuke
derkenuke
Colaborador
 
Fecha de Ingreso: octubre-2003
Ubicación: self.location.href
Mensajes: 2.665
Antigüedad: 20 años, 6 meses
Puntos: 45
Re: Alguna sugerencia para hacer esto..=?

Hola m_ecano:

Vamos a ver si he entendido tu duda bien. ¿Quieres una estructura HTML para un formulario que te permita seleccionar todo lo que has escrito en esa ristra de números y operadores lógicos? ¿O quieres que una función javascript te genere el formulario dada una cadena de esa sintaxis?

Lo segundo es un poquito más complicado, lo primero se puede hacer utilizando un par de checkboxes. Lo primero que hay que hacer es dibujarlo:
Código:
( 
	( 
		(10 ^ 20) (15 | 16 | 18) 
	) 
	^ 
	( 
		(13 | 20) | (01 | 20) 
	) 
) 
| 
(
	20
)
Yo por lo menos así lo veo mejor. Ocupémonos de elemento por elemento. He hecho algo así:

Código PHP:

<!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" xml:lang="es" lang="es">
<
head>
<
meta http-equiv="Content-type" content="text/html;charset=iso-8859-1" />
<
meta name="Author" content="derkeNuke" />
<
title>Página nueva</title>
<
style type="text/css">
#fr #divNo20 {
    
margin-left2em;
    
displaynone;
}
#fr #div13o20 {
    
margin-left2em;
    
displaynone;
}
#fr #div01o20 {
    
margin-left2em;
    
displaynone;
}
</
style>
</
head>

<
body>

<!--

    ( 
        (
10 20) (15 16 18
    ) 
    ^ 
    ( 
        (
13 20) | (01 20
    ) 


(
    
20
)
-->


<
script type="text/javascript">
<!--


// document.getElementById abreviado
function $(x) { return document.getElementById(x); }


function 
setDisplay(idCapadsp) {
    $(
idCapa).style.display dsp;
}



// -->
</script>

<form id="fr" onsubmit="return true;">

<input type="radio" name="inicial20" id="opcionVariada" onfocus="setDisplay('divNo20', 'block')" /><label for="opcionVariada">No 20</label> <br/>
<div id="divNo20">
    <input type="checkbox" id="opcion10y20"/><label for="opcion10y20">10 y 20</label> <br/>
    <input type="radio" name="de15a18" id="opcion15"/><label for="opcion15">15</label> <br/>
    <input type="radio" name="de15a18" id="opcion16"/><label for="opcion16">16</label> <br/>
    <input type="radio" name="de15a18" id="opcion18"/><label for="opcion18">18</label> <br/>

    <input type="radio" name="opcion1320o0120" id="opcion13o20" onfocus="setDisplay('div13o20', 'block'); setDisplay('div01o20', 'none')"/><label for="opcion13o20">13 ó 20</label> <br/>
    <div id="div13o20">
        <input type="radio" name="opcion13y20" id="opcion13"/><label for="opcion13">13</label> <br/>
        <input type="radio" name="opcion13y20" id="opcion20_1"/><label for="opcion20_1">20</label> <br/>
    </div>
    <input type="radio" name="opcion1320o0120" id="opcion01o20" onfocus="setDisplay('div13o20', 'none'); setDisplay('div01o20', 'block')"/><label for="opcion01o20">01 ó 20</label> <br/>
    <div id="div01o20">
        <input type="radio" name="opcion01y20" id="opcion01"/><label for="opcion01">01</label> <br/>
        <input type="radio" name="opcion01y20" id="opcion20_2"/><label for="opcion20_2">20</label> <br/>
    </div>
</div>
<input type="radio" name="inicial20" id="opcion20_3" onfocus="setDisplay('divNo20', 'none')" /><label for="opcion20_3">20</label> <br/>

<button type="submit">Enviar</button>
</form>



</body>
</html> 

Espero que sea lo que estabas buscando.



Un saludo
__________________
- Haz preguntas inteligentes, y obtendrás más y mejores respuestas.
- Antes de postearlo Inténtalo y Búscalo.
- Escribe correctamente tus mensajes.