aej1973
asked on
value of drop down 2 depends on value of drop down 1 ; PHP
I have two drop down menus that are being dynamically populated from an mysql database.
Drop down 1 will look like this:
Now depending on the vendor ID my next field on my form (which is a drop down menu) needs to be populated accordingly. My table looks like this;
ph_id vendor_id number status
1 1 616 1
2 1 214 1
3 2 845 1
4 2 801 1
My second menu item should look like this:
Drop down 1 will look like this:
$stmt2 = $db->query('SELECT vendor_id, vendor_name from vendor_inbound ');
$vSelect2 = '<select size="1" name="vendor">' . "\n";
while($row2 = $stmt2->fetch(PDO::FETCH_ASSOC)){
$vSelect2 .= '<option value="'.$row2['vendor_id'].'">'.$row2['vendor_name'].'</option>' . "\n";
}//end while
$vSelect2 .= '</select>' . "\n";
.Now depending on the vendor ID my next field on my form (which is a drop down menu) needs to be populated accordingly. My table looks like this;
ph_id vendor_id number status
1 1 616 1
2 1 214 1
3 2 845 1
4 2 801 1
My second menu item should look like this:
$stmt3 = $db->query('SELECT number from did where vendor_id ="$id" ');
$vSelect3 = '<select size="1" name="did">' . "\n";
while($row3 = $stmt3->fetch(PDO::FETCH_ASSOC)){
$vSelect3 .= '<option value="'.$row3['number'].'">'.$row3['number'].'</option>' . "\n";
}//end while
$vSelect2 .= '</select>' . "\n";
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
if the value is not passed, maybe
[ ] - your page/form is malformed (can check that for you, go to http://validator.w3.org/)
[ ] - the field is outside the submitted form (look like it's inside)
[ ] - there's no name attribute to the field (look like there's one)
There's no relative issue with cascading dropdown and ajax
[ ] - your page/form is malformed (can check that for you, go to http://validator.w3.org/)
[ ] - the field is outside the submitted form (look like it's inside)
[ ] - there's no name attribute to the field (look like there's one)
There's no relative issue with cascading dropdown and ajax
ASKER
Thank you very much it works! I appreciate your help.
A
A
ASKER
A