loomer
05-31-2003, 10:46 PM
Okay here is the situation:
I'm using PHP, Javscript and mySQL for this project. I have successfully created a dynamic drop down menu. The second drop drown will change depending on the what the user chooses for the first menu.
What I would like to do is have a button(picture) that can change the selected item in the second drop down menu using the onClick command.
For example, the first drop down is metal alloys, the second is the product line (I-Beam, Round, Hex, etc.). I have an accompanying picture of each of the product lines. So I would like the user to be able to click on the picture and have it change the value of the second drop down. I'm not sure if this can be done or how to access it through the DOM.
I REALLY need some help on this so any tips would be greatly appreciated. Thanks.
Here is the jist of the code I'm using (after PHP has translated the page):
<!-- ALLOY SELECT-->
<td colspan="8" width="112" height="42" align="left" valign="top" bgcolor="#999999">
<select class="drop" name="Alloy" onChange="alloyselected(this);" >
<option value="" class=""><b>Select an Alloy</b></option>
<option value="">---------------</option>
<option value='1'>Aluminum</option>
<option value='4'>Commercial</option>
<option value='3'>Copper</option>
<option value='5'>Nickel</option>
<option value='2'>Steel</option>
</select>
<!-- PRODUCT LINE SELECT -->
<select class="drop" name="proLine">
<option value="" class=""><b>Select an Alloy</b></option>
<option value="">---------------</option>
</select>
<SCRIPT LANGUAGE="JavaScript">
function alloyselected(elem){
for (var i = document.f1.proLine.options.length; i >= 0; i--){
document.f1.proLine.options[i] = null;
}
if (elem.options[elem.selectedIndex].value==1){
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Zee','18');
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Angle','1');
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Hollow Tube','3');
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('I-Beam','10');
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Rectangle','13');
}
if (elem.options[elem.selectedIndex].value==4){
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Hex','12');
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Zee','19');
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Angle','2');
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Hollow Tube','6');
}
if (elem.options[elem.selectedIndex].value==3){
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Round','8');
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Hex','11');
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Channel','15');
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Hollow Tube','5');
}
if (elem.options[elem.selectedIndex].value==5){
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Rectangle','14');
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Tee','17');
}
if (elem.options[elem.selectedIndex].value==2){
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Hollow Tube','4');
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Round','7');
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('I-Beam','9');
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Channel','16');
}
}
</SCRIPT>
I'm using PHP, Javscript and mySQL for this project. I have successfully created a dynamic drop down menu. The second drop drown will change depending on the what the user chooses for the first menu.
What I would like to do is have a button(picture) that can change the selected item in the second drop down menu using the onClick command.
For example, the first drop down is metal alloys, the second is the product line (I-Beam, Round, Hex, etc.). I have an accompanying picture of each of the product lines. So I would like the user to be able to click on the picture and have it change the value of the second drop down. I'm not sure if this can be done or how to access it through the DOM.
I REALLY need some help on this so any tips would be greatly appreciated. Thanks.
Here is the jist of the code I'm using (after PHP has translated the page):
<!-- ALLOY SELECT-->
<td colspan="8" width="112" height="42" align="left" valign="top" bgcolor="#999999">
<select class="drop" name="Alloy" onChange="alloyselected(this);" >
<option value="" class=""><b>Select an Alloy</b></option>
<option value="">---------------</option>
<option value='1'>Aluminum</option>
<option value='4'>Commercial</option>
<option value='3'>Copper</option>
<option value='5'>Nickel</option>
<option value='2'>Steel</option>
</select>
<!-- PRODUCT LINE SELECT -->
<select class="drop" name="proLine">
<option value="" class=""><b>Select an Alloy</b></option>
<option value="">---------------</option>
</select>
<SCRIPT LANGUAGE="JavaScript">
function alloyselected(elem){
for (var i = document.f1.proLine.options.length; i >= 0; i--){
document.f1.proLine.options[i] = null;
}
if (elem.options[elem.selectedIndex].value==1){
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Zee','18');
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Angle','1');
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Hollow Tube','3');
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('I-Beam','10');
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Rectangle','13');
}
if (elem.options[elem.selectedIndex].value==4){
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Hex','12');
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Zee','19');
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Angle','2');
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Hollow Tube','6');
}
if (elem.options[elem.selectedIndex].value==3){
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Round','8');
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Hex','11');
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Channel','15');
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Hollow Tube','5');
}
if (elem.options[elem.selectedIndex].value==5){
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Rectangle','14');
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Tee','17');
}
if (elem.options[elem.selectedIndex].value==2){
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Hollow Tube','4');
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Round','7');
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('I-Beam','9');
document.f1.proLine.options[document.f1.proLine.options.length] = new Option('Channel','16');
}
}
</SCRIPT>