Hi,
I am having a problem as I know very little about javascript.
I have a form with 3 drop down boxes - the first box is a populated using thestandard <SELECT> tag.
The 2nd box is populated with values depending on the choice made in the 1st box, and the 3rd box depends on the choice in the 2nd.
This all works fine.
However, I want to be able to display some explanation text after the first drop down box - and the text will depend on the choice made in the first box.
This is where I have no idea!
Any help gratefully received!
My code so far:
<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var arrItems1 = new Array();
var arrItemsGrp1 = new Array();
<!-- Designer -->
arrItems1[1] = "Standard";
arrItemsGrp1[1] = 1;
arrItems1[2] = "Educational";
arrItemsGrp1[2] = 1;
<!-- End of Designer -->
<!-- CorelDraw Graphics Suite -->
arrItems1[3] = "Standard";
arrItemsGrp1[3] = 2;
<!-- End of CorelDraw Graphics Suite -->
<!-- Grafigo -->
arrItems1[4] = "Standard";
arrItemsGrp1[4] = 3;
<!-- End of Grafigo -->
<!-- Ventura -->
arrItems1[5] = "Standard";
arrItemsGrp1[5] = 4;
arrItems1[6] = "Educational";
arrItemsGrp1[6] = 4;
<!-- End of Ventura -->
<!-- Paradox Standalone -->
arrItems1[7] = "Standard";
arrItemsGrp1[7] = 5;
<!-- End of Paradox Standalone -->
<!-- Painter -->
arrItems1[8] = "Standard";
arrItemsGrp1[8] = 6;
arrItems1[9] = "Educational";
arrItemsGrp1[9] = 6;
<!-- End of Painter -->
<!-- WordPerfect Office Standard -->
arrItems1[10] = "Standard";
arrItemsGrp1[10] = 7;
arrItems1[11] = "Educational";
arrItemsGrp1[11] = 7;
<!-- End of WordPerfect Office Standard -->
<!-- WordPerfect Office Standard -->
arrItems1[12] = "Standard";
arrItemsGrp1[12] = 8;
<!-- End of WordPerfect Office Standard -->
var arrItems2 = new Array();
var arrItemsGrp2 = new Array();
<!-- Designer -->
arrItems2[2000] = "New Licence";
arrItemsGrp2[2000] = 1;
arrItems2[2001] = "Upgrade Licence";
arrItemsGrp2[2001] = 1;
arrItems2[2002] = "Maintenance";
arrItemsGrp2[2002] = 1;
arrItems2[2003] = "New Licence";
arrItemsGrp2[2003] = 2;
arrItems2[2005] = "Maintenance";
arrItemsGrp2[2005] = 2;
<!-- End of Designer -->
<!-- CorelDraw Graphics Suite -->
arrItems2[2006] = "New Licence";
arrItemsGrp2[2006] = 3;
arrItems2[2007] = "Upgrade Licence";
arrItemsGrp2[2007] = 3;
arrItems2[2008] = "Maintenance";
arrItemsGrp2[2008] = 3;
<!-- End of CorelDraw Graphics Suite -->
<!-- Grafigo -->
arrItems2[2009] = "New Licence";
arrItemsGrp2[2009] = 4;
<!-- End of Grafigo -->
<!-- Ventura -->
arrItems2[2010] = "New Licence";
arrItemsGrp2[2010] = 5;
arrItems2[2011] = "Upgrade Licence";
arrItemsGrp2[2011] = 5;
arrItems2[2012] = "Maintenance";
arrItemsGrp2[2012] = 5;
arrItems2[2013] = "New Licence";
arrItemsGrp2[2013] = 6;
<!-- End of Ventura -->
<!-- Paradox Standalone -->
arrItems2[2014] = "New Licence";
arrItemsGrp2[2014] = 7;
arrItems2[2015] = "Upgrade Licence";
arrItemsGrp2[2015] = 7;
<!-- end of Paradox Standalone -->
<!-- Ventura -->
arrItems2[2016] = "New Licence";
arrItemsGrp2[2016] = 8;
arrItems2[2017] = "Upgrade Licence";
arrItemsGrp2[2017] = 8;
arrItems2[2018] = "Maintenance";
arrItemsGrp2[2018] = 8;
arrItems2[2019] = "New Licence";
arrItemsGrp2[2019] = 9;
arrItems2[2020] = "Maintenance";
arrItemsGrp2[2020] = 9;
<!-- End of Ventura -->
<!-- WordPerfect Office Standard -->
arrItems2[2021] = "New Licence";
arrItemsGrp2[2021] = 10;
arrItems2[2022] = "Upgrade Licence";
arrItemsGrp2[2022] = 10;
arrItems2[2023] = "Maintenance - 1 year";
arrItemsGrp2[2023] = 10;
arrItems2[2024] = "Maintenance - 2 years";
arrItemsGrp2[2024] = 10;
arrItems2[2025] = "New Licence";
arrItemsGrp2[2025] = 11;
arrItems2[2026] = "Maintenance - 1 year";
arrItemsGrp2[2026] = 11;
arrItems2[2027] = "Maintenance - 2 years";
arrItemsGrp2[2027] = 11;
<!-- End of WordPerfect Office Standard -->
<!-- WordPerfect Office Professional -->
arrItems2[2028] = "New Licence";
arrItemsGrp2[2028] = 12;
arrItems2[2029] = "Upgrade Licence";
arrItemsGrp2[2029] = 12;
arrItems2[2030] = "Maintenance - 1 year";
arrItemsGrp2[2030] = 12;
arrItems2[2031] = "Maintenance - 2 years";
arrItemsGrp2[2031] = 12;
<!-- End of WordPerfect Office Professional -->
function selectChange(control, controlToPopulate, ItemArray, GroupArray)
{
var myEle ;
var x ;
// Empty the second drop down box of any choices
for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;
if (control.name == "firstChoice") {
// Empty the third drop down box of any choices
for (var q=myChoices.thirdChoice.options.length;q>=0;q--) myChoices.thirdChoice.options[q] = null;
}
// ADD Default Choice - in case there are no values
myEle = document.createElement("option") ;
myEle.value = 0 ;
myEle.text = "-- please select --" ;
controlToPopulate.add(myEle) ;
// Now loop through the array of individual items
// Any containing the same child id are added to
// the second dropdown box
for ( x = 0 ; x < ItemArray.length ; x++ )
{
if ( GroupArray[x] == control.value )
{
myEle = document.createElement("option") ;
myEle.value = x ;
myEle.text = ItemArray[x] ;
controlToPopulate.add(myEle) ;
}
}
}
// End -->
</script>
</head>
<body>
<form name="myChoices" method="post" action="corel_result.php">
<table width="100%" align="center">
<tr>
<td width="40%"> <div align="right"> Product</div></TD>
<td width="5%"> <div align="center">:</div></TD>
<td> <SELECT id=firstChoice name=firstChoice onchange="selectChange(this, myChoices.secondChoice, arrItems1, arrItemsGrp1);">
<option value=0 SELECTED>-- please select --</option>
<option value=1>Corel Designer</option>
<option value=2>CorelDraw Graphics Suite</option>
<option value=3>Corel Grafigo</option>
<option value=4>Corel Ventura</option>
<option value=5>Paradox Standalone</option>
<option value=6>Corel Painter</option>
<option value=7>WordPerfect Office Standard</option>
<option value=8>WordPerfect Office Professional</option>
</SELECT> </TD>
</TR>
<TR>
<TD><div align="right">Standard or Educational</div></TD>
<TD><div align="center">:</div></TD>
<TD> <SELECT id=secondChoice name=secondChoice onchange="selectChange(this, myChoices.thirdChoice, arrItems2, arrItemsGrp2);">
</SELECT></TD>
</TR>
<TR>
<TD><div align="right">Licence Type</div></TD>
<TD><div align="center">:</div></TD>
<TD> <SELECT id=thirdChoice name=thirdChoice onchange="selectChange(this, myChoices.fourthChoice, arrItems3, arrItemsGrp3);">
</SELECT></TD>
</TR>
<TR>
<TD><div align="right"></div></TD>
<TD><div align="center"></div></TD>
<TD> </TD>
</TR>
<TR>
<TD><div align="right">Number of Licences Required</div></TD>
<TD><div align="center">:</div></TD>
<TD><INPUT TYPE=text SIZE=5 NAME=licence_numbers></TD>
</TR>
<TR>
<TD> </TD>
<TD> </TD>
<TD><INPUT TYPE=submit VALUE="Get Quote"></TD>
</TR>
</TABLE>
</form>
</body>
I am having a problem as I know very little about javascript.
I have a form with 3 drop down boxes - the first box is a populated using thestandard <SELECT> tag.
The 2nd box is populated with values depending on the choice made in the 1st box, and the 3rd box depends on the choice in the 2nd.
This all works fine.
However, I want to be able to display some explanation text after the first drop down box - and the text will depend on the choice made in the first box.
This is where I have no idea!
Any help gratefully received!
My code so far:
<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var arrItems1 = new Array();
var arrItemsGrp1 = new Array();
<!-- Designer -->
arrItems1[1] = "Standard";
arrItemsGrp1[1] = 1;
arrItems1[2] = "Educational";
arrItemsGrp1[2] = 1;
<!-- End of Designer -->
<!-- CorelDraw Graphics Suite -->
arrItems1[3] = "Standard";
arrItemsGrp1[3] = 2;
<!-- End of CorelDraw Graphics Suite -->
<!-- Grafigo -->
arrItems1[4] = "Standard";
arrItemsGrp1[4] = 3;
<!-- End of Grafigo -->
<!-- Ventura -->
arrItems1[5] = "Standard";
arrItemsGrp1[5] = 4;
arrItems1[6] = "Educational";
arrItemsGrp1[6] = 4;
<!-- End of Ventura -->
<!-- Paradox Standalone -->
arrItems1[7] = "Standard";
arrItemsGrp1[7] = 5;
<!-- End of Paradox Standalone -->
<!-- Painter -->
arrItems1[8] = "Standard";
arrItemsGrp1[8] = 6;
arrItems1[9] = "Educational";
arrItemsGrp1[9] = 6;
<!-- End of Painter -->
<!-- WordPerfect Office Standard -->
arrItems1[10] = "Standard";
arrItemsGrp1[10] = 7;
arrItems1[11] = "Educational";
arrItemsGrp1[11] = 7;
<!-- End of WordPerfect Office Standard -->
<!-- WordPerfect Office Standard -->
arrItems1[12] = "Standard";
arrItemsGrp1[12] = 8;
<!-- End of WordPerfect Office Standard -->
var arrItems2 = new Array();
var arrItemsGrp2 = new Array();
<!-- Designer -->
arrItems2[2000] = "New Licence";
arrItemsGrp2[2000] = 1;
arrItems2[2001] = "Upgrade Licence";
arrItemsGrp2[2001] = 1;
arrItems2[2002] = "Maintenance";
arrItemsGrp2[2002] = 1;
arrItems2[2003] = "New Licence";
arrItemsGrp2[2003] = 2;
arrItems2[2005] = "Maintenance";
arrItemsGrp2[2005] = 2;
<!-- End of Designer -->
<!-- CorelDraw Graphics Suite -->
arrItems2[2006] = "New Licence";
arrItemsGrp2[2006] = 3;
arrItems2[2007] = "Upgrade Licence";
arrItemsGrp2[2007] = 3;
arrItems2[2008] = "Maintenance";
arrItemsGrp2[2008] = 3;
<!-- End of CorelDraw Graphics Suite -->
<!-- Grafigo -->
arrItems2[2009] = "New Licence";
arrItemsGrp2[2009] = 4;
<!-- End of Grafigo -->
<!-- Ventura -->
arrItems2[2010] = "New Licence";
arrItemsGrp2[2010] = 5;
arrItems2[2011] = "Upgrade Licence";
arrItemsGrp2[2011] = 5;
arrItems2[2012] = "Maintenance";
arrItemsGrp2[2012] = 5;
arrItems2[2013] = "New Licence";
arrItemsGrp2[2013] = 6;
<!-- End of Ventura -->
<!-- Paradox Standalone -->
arrItems2[2014] = "New Licence";
arrItemsGrp2[2014] = 7;
arrItems2[2015] = "Upgrade Licence";
arrItemsGrp2[2015] = 7;
<!-- end of Paradox Standalone -->
<!-- Ventura -->
arrItems2[2016] = "New Licence";
arrItemsGrp2[2016] = 8;
arrItems2[2017] = "Upgrade Licence";
arrItemsGrp2[2017] = 8;
arrItems2[2018] = "Maintenance";
arrItemsGrp2[2018] = 8;
arrItems2[2019] = "New Licence";
arrItemsGrp2[2019] = 9;
arrItems2[2020] = "Maintenance";
arrItemsGrp2[2020] = 9;
<!-- End of Ventura -->
<!-- WordPerfect Office Standard -->
arrItems2[2021] = "New Licence";
arrItemsGrp2[2021] = 10;
arrItems2[2022] = "Upgrade Licence";
arrItemsGrp2[2022] = 10;
arrItems2[2023] = "Maintenance - 1 year";
arrItemsGrp2[2023] = 10;
arrItems2[2024] = "Maintenance - 2 years";
arrItemsGrp2[2024] = 10;
arrItems2[2025] = "New Licence";
arrItemsGrp2[2025] = 11;
arrItems2[2026] = "Maintenance - 1 year";
arrItemsGrp2[2026] = 11;
arrItems2[2027] = "Maintenance - 2 years";
arrItemsGrp2[2027] = 11;
<!-- End of WordPerfect Office Standard -->
<!-- WordPerfect Office Professional -->
arrItems2[2028] = "New Licence";
arrItemsGrp2[2028] = 12;
arrItems2[2029] = "Upgrade Licence";
arrItemsGrp2[2029] = 12;
arrItems2[2030] = "Maintenance - 1 year";
arrItemsGrp2[2030] = 12;
arrItems2[2031] = "Maintenance - 2 years";
arrItemsGrp2[2031] = 12;
<!-- End of WordPerfect Office Professional -->
function selectChange(control, controlToPopulate, ItemArray, GroupArray)
{
var myEle ;
var x ;
// Empty the second drop down box of any choices
for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;
if (control.name == "firstChoice") {
// Empty the third drop down box of any choices
for (var q=myChoices.thirdChoice.options.length;q>=0;q--) myChoices.thirdChoice.options[q] = null;
}
// ADD Default Choice - in case there are no values
myEle = document.createElement("option") ;
myEle.value = 0 ;
myEle.text = "-- please select --" ;
controlToPopulate.add(myEle) ;
// Now loop through the array of individual items
// Any containing the same child id are added to
// the second dropdown box
for ( x = 0 ; x < ItemArray.length ; x++ )
{
if ( GroupArray[x] == control.value )
{
myEle = document.createElement("option") ;
myEle.value = x ;
myEle.text = ItemArray[x] ;
controlToPopulate.add(myEle) ;
}
}
}
// End -->
</script>
</head>
<body>
<form name="myChoices" method="post" action="corel_result.php">
<table width="100%" align="center">
<tr>
<td width="40%"> <div align="right"> Product</div></TD>
<td width="5%"> <div align="center">:</div></TD>
<td> <SELECT id=firstChoice name=firstChoice onchange="selectChange(this, myChoices.secondChoice, arrItems1, arrItemsGrp1);">
<option value=0 SELECTED>-- please select --</option>
<option value=1>Corel Designer</option>
<option value=2>CorelDraw Graphics Suite</option>
<option value=3>Corel Grafigo</option>
<option value=4>Corel Ventura</option>
<option value=5>Paradox Standalone</option>
<option value=6>Corel Painter</option>
<option value=7>WordPerfect Office Standard</option>
<option value=8>WordPerfect Office Professional</option>
</SELECT> </TD>
</TR>
<TR>
<TD><div align="right">Standard or Educational</div></TD>
<TD><div align="center">:</div></TD>
<TD> <SELECT id=secondChoice name=secondChoice onchange="selectChange(this, myChoices.thirdChoice, arrItems2, arrItemsGrp2);">
</SELECT></TD>
</TR>
<TR>
<TD><div align="right">Licence Type</div></TD>
<TD><div align="center">:</div></TD>
<TD> <SELECT id=thirdChoice name=thirdChoice onchange="selectChange(this, myChoices.fourthChoice, arrItems3, arrItemsGrp3);">
</SELECT></TD>
</TR>
<TR>
<TD><div align="right"></div></TD>
<TD><div align="center"></div></TD>
<TD> </TD>
</TR>
<TR>
<TD><div align="right">Number of Licences Required</div></TD>
<TD><div align="center">:</div></TD>
<TD><INPUT TYPE=text SIZE=5 NAME=licence_numbers></TD>
</TR>
<TR>
<TD> </TD>
<TD> </TD>
<TD><INPUT TYPE=submit VALUE="Get Quote"></TD>
</TR>
</TABLE>
</form>
</body>