lunes, 10 de septiembre de 2007

Combobox relacionados dinamicos entre si

<script language="javascript">

function setOptions(chosen)
{
var selbox = document.miformu.opttwo;

selbox.options.length = 0;

if (chosen == " ")
{
selbox.options[selbox.options.length] = new Option('Please select one of the options above first',' ');
}

if (chosen == "1")
{
selbox.options[selbox.options.length] = new Option('first choice - option one','oneone');
selbox.options[selbox.options.length] = new Option('first choice - option two','onetwo');
}

if (chosen == "2")
{
selbox.options[selbox.options.length] = new Option('second choice - option one','twoone');
selbox.options[selbox.options.length] = new Option('second choice - option two','twotwo');
}

if (chosen == "3")
{
selbox.options[selbox.options.length] = new Option('third choice - option one','threeone');
selbox.options[selbox.options.length] = new Option('third choice - option two','threetwo');
}

}
</script>


<form name="miformu">
<div align="center">
<select name="optone" size="1" onchange="setOptions(document.miformu.optone.options[document.miformu.optone.selectedIndex].value);">
<option value=" " selected="selected"> </option>
<option value="1">First Choice</option>
<option value="2">Second Choice</option>
<option value="3">Third Choice</option>
</select>

<br><br>

<select name="opttwo" size="1">
<option value=" " selected="selected">Please select one of the options above first</option>
</select>

<input type="button" name="go" value="Value Selected" onclick="alert(document.miformu.opttwo.options[document.miformu.opttwo.selectedIndex].value);">
</div>
</form>

2 comentarios:

Anónimo dijo...

Es increible como internet ha ayudado a la divulgacion de estos temas. cotizacion dolar
bad credit loans for unemployed

Anónimo dijo...

Muy buen articulo, estoy casi 100% de acuerdo contigo :)