Non ho molto tempo quindi adatta questo:
codice:
<HTML><HEAD>
<TITLE>Untitled</TITLE>
</HEAD>
<BODY>
<SCRIPT language=javascript>
var iArrayMax = 7
var aDropdown = new Array(iArrayMax)
//as the page loads - first thing to do is to load the dropdown array
var bOk = LoadArrays()
function LoadArrays()
{
//this can be thought of as an object array, each element can be identified as a property of the array position
// a very powerful structure for 'client side' data caching.
Array[0] = new sElement('SO','Mac','Machintosh')
Array[1] = new sElement('SO','lix','Linux')
Array[2] = new sElement('SO','win','Windows')
Array[3] = new sElement('SO','Alt','Altri')
Array[4] = new sElement('MC','dw','Dreamwaver')
Array[5] = new sElement('MC','fl','Flash')
Array[6] = new sElement('MC','fh','Freehand')
Array[7] = new sElement('MC','fw','Fireworks')
return true
}
function sElement(sParentId,sValue,sDescription)
{
// elements that will be loaded into the array structure and persisted
// think of it as an object.
this.ParentId = sParentId
this.Id = sValue
this.Description = sDescription
}
function bCascadeDrop(oDDsource,oDDdest)
{
//function to enable cascading dropdowns
//called as the parent dropdown changes.
var iX
var sText
var iY= 0
var sOptionId
var sOptionDesc
var iStartPos
//find the value of the item currently selected
sText = oDDsource.options[oDDsource.selectedIndex].value
if (sText != '0')
{
//clear down the destination list box
oDDdest.options.length = 0
//loop through the elements that are in the array
// if they match the parent if then they should be displayed.
for (iX=0; iX<=iArrayMax; iX++)
{
if(sText == Array[iX].ParentId)
{
//grab the values out of the element (Netscape is not happy doing too many things in a function call!)
sOptionId = Array[iX].Id
sOptionDesc= Array[iX].Description
//alert(sOptionDesc)
//write the element into the dripdown box.
oDDdest.options[iY] = new Option (sOptionDesc,sOptionId)
iY = iY +1
}
}
}
}
</SCRIPT>
<FORM action=FrmNew>
<TABLE>
<TBODY>
<TR>
<TD>Categoria</TD>
<TD><SELECT style="WIDTH: 150px" onchange="bCascadeDrop(this, document.forms[0].sRegion)" name=sCountry>
<OPTION value=0 selected>Categoria...</OPTION> <OPTION
value=SO>Sistema operativo</OPTION> <OPTION
value=MC>Macromedia</OPTION></SELECT> Sottocategoria <SELECT style="WIDTH: 150px" name=sRegion size="1"><OPTION value=0 selected><---------------------</OPTION> </SELECT>
</TD></TR>
</TBODY></TABLE></FORM></BODY></HTML>
Se proprio non riesci chiedi pure chiarimenti al sottoscritto che proverò a risolverti i problemi....