Francisco Meirelles
|
| Posted: 05/21/2004, 7:50 AM |
|
I would like to make a formulario with two fields:
radio and listbox
listbox is dependent of the radio selects.
example:
=================
<form name=form1 >
Ensino Médio <input type="radio" value=1 name="r" onclick=qual() >
<br>
Ensino Superior <input type="radio" value=2 name="r" onclick=qual() >
<br>
Opções:
<SELECT ID="listagem">
<OPTION selected>Escolha</OPTION>
</SELECT>
</form>
<SCRIPT>
function qual()
{
var n = form1.r.length
for(x=0; x<=n; x++)
{
if( form1.r[x].checked )
{
if (x==0)
{
criar( 3 );
}
else
{
criar( 12 );
}
}
}
}
function criar(a)
{
if (a == 3)
{
Texto = "º Ano "
}
else
{
Texto = "º Período "
}
destruir(form1.listagem);
for (x = 0 ; x < a ; x++)
{
NovaOP = new Option();
if ( (x+1) <= 9 )
{
NovaOP.text = "0" + (x+1) + Texto ;
}
else
{
NovaOP.text = "" + (x+1) + Texto ;
}
form1.listagem.add(NovaOP, 1);
}
OrdenaCombo(form1.listagem);
}
function destruir(combo)
{
var n = combo.options.length
for(i=0; i<n; i++)
{
combo.options[0] = null;
}
}
function OrdenaCombo(combo)
{
var Textos = new Array()
var Valores = new Array()
var n = combo.options.length
for(i=0; i<n; i++)
{
Textos = combo.options.text;
Valores = combo.options.value;
}
for (i=0; i<n; i++)
{
for (j=0; j<n-i; j++)
if (Textos[j+1] < Textos[j])
{
tmp = Textos[j];
Textos[j] = Textos[j+1];
Textos[j+1] = tmp;
tmp = Valores[j];
Valores[j] = Valores[j+1];
Valores[j+1] = tmp;
}
}
for(i=0; i<n; i++)
{
combo.options[0] = null;
}
for(i=0; i<n; i++)
{
combo.options = new Option(Textos,Valores);
}
}
</script>
=================
how to make this in codecharge?
|
|
|
 |
|