I am busy creating a online order form. In the order lines there are two dropdown fields. The second need to be updated after a selection is made in the first.
This is the JAVA Code for that
JAVA-------------------------------------------------------------
function Populatecolor(FinishList,ColorList) {
// Clear out the list of color
ClearOptions(ColorList);
if (FinishList[FinishList.selectedIndex].value == "Mill") {
AddToOptionList(ColorList, "Choose A Color", "Choose A Color");
AddToOptionList(ColorList, "Natural", "Natural");
}
if (FinishList[FinishList.selectedIndex].value == "Anodized") {
AddToOptionList(ColorList, "Choose A Color", "Choose A Color");
AddToOptionList(ColorList, "Black", "Black");
AddToOptionList(ColorList, "Bronze", "Bronze");
AddToOptionList(ColorList, "Natural", "Natural");
}
if (FinishList[FinishList.selectedIndex].value == "Powder Coat") {
AddToOptionList(ColorList, "Choose A Color", "Choose A Color");
AddToOptionList(ColorList, "White", "White");
AddToOptionList(ColorList, "Bronze", "Bronze");
}
}
function ClearOptions(OptionList) {
for (x = OptionList.length; x >= 0; x = x - 1) {
OptionList[x] = null;
}
}
function AddToOptionList(OptionList, OptionValue, OptionText) {
// Add option to the bottom of the list
OptionList[OptionList.length] = new Option(OptionText, OptionValue);
}
-----------------------------------------------------------------------------JAVA
In my PHP script I build a table bu running a for loop and call the script like this.
<td width="14%">
<select name="ProdFinish[' . $i . ']" onChange="Populatecolor(ProdFinish[' . $i . '],ProdColor[' . $i . '])">
<option>Choose a Finish</option>
<option value="Mill">Mill</option>
<option value="Anodized">Anodized</option>
<option value="Powder Coat">Powder Coat</option>
</select>
</td>
I need to display the field again after the add row is selected but no drop down box will appear. just the text. I can display the text fine with the [] brackets but then my JAVA doesnt work. As I take out the [] the java works but I cannot reference the variable.
Can I do this in PHP. Full source can be supplied.
Thanx