Hi,
I'm really stuck here, as beginner of coding...
Found very nice code for populate array to form. But i need filter more with "Product type", in case of massive amount of products.
Following scripts works as individual actions, but i need to query by firstly selected "Types"
tried to get heading from first query and use it with WHERE clause in second query. But it gives only last value of first query result.
So, i think, i have to do this in java-script section. I'm very bad with java, so if someone can help with this. Or have an better idea to make it work?
PHP script:__________________________________________________________________
$vbCrLf = chr(13).chr(10);
$query = mysqli_query($db,"SELECT DISTINCT ProdType FROM product ORDER BY ProdType ASC");
$result = ($query) or die ('Error in query: $query. ' . mysqli_error());
$DropDownList .= "<select name='Types' id='DropDownListId' onchange='javascript:SelectChanged();'>".$vbCrLf;
$DropDownList .= "<option value=''>Select Type...</option>".$vbCrLf;
while($row = mysqli_fetch_row($result))
{
$heading = $row[0];
$DropDownList .= "<option value='$heading'>$heading</option>".$vbCrLf;
$ProdTypesArrayPhp .= 'ProdTypesArrayPhp["'.$heading.'"]="'.$row[0].'";'.$vbCrLf;
}
$DropDownList .= "</select> ".$vbCrLf;
$query1 = mysqli_query($db,"SELECT ProductName, ProductItem, ProdType, Tax, RetailPrice FROM product ORDER BY ProductName");
$result1 = ($query1) or die ('Error in query: $query1. ' . mysqli_error());
$DropDownList1 .= "<select name='ProductName' id='DropDownListId1' onchange='javascript:SelectChanged1();'>".$vbCrLf;
$DropDownList1 .= "<option value=''>Select Product...</option>".$vbCrLf;
while($row = mysqli_fetch_row($result1))
{
$heading1 = $row[0];
Java script:__________________________________________________________________________
function SelectChanged()
{
var Types=document.getElementById('DropDownListId').value;
document.getElementById('Types').value=ProdTypesArrayPhp[Types];
}
function SelectChanged1()
{
var ProductName=document.getElementById('DropDownListId1').value;
document.getElementById('ProductName').value=ProductNameArray[ProductName];
document.getElementById('ProductItem').value=ProductItemArray[ProductName];
document.getElementById('ProdType').value=ProdTypeArray[ProductName];
document.getElementById('Tax').value=TaxArray[ProductName];
document.getElementById('RetailPrice').value=RetailPriceArray[ProductName];
document.getElementById('OrderedAmt').value=1;
document.getElementById('Total').value=RetailPriceArray[ProductName];
}