Hi i have 2 dropdown menu and i want populate my 2nd dropdown menu items with my 1st dropdown menu item related. I mean my 1st dropdown menu items are Apple, Samsung, HTC, Nokia etc. When i select Apple dropdown menu items populated by iPhone 6s, iPhone 5s, iPhone 4s etc. I can't explain it very well in english. Sorry my bad english. I populated my 1st dropdown menu from database
function selectFactor(){
$result = @mysql_query("SELECT * from Factors");
while($record = @mysql_fetch_array($result)){
echo '<option value="'.$record['FactorID'].'">'.$record['FactorName'].'</option>';
}
}
and display result in html file
<select name="dropdown" id="dropdown" onchange="bla()">
<?php selectFactor(); ?>
</select>
and i just try something with it bla bla bla...
function bla(){
var e = document.getElementById("dropdown");
var elementValue = e.options[e.selectedIndex].value;
console.log(elementValue);
}
how can i populate 2nd dropdown menu when 1st index is changed? UPDATED!
<?php
$name = $_POST['selectedItem'];
function selectSum(){
$result = @mysql_query("SELECT * from factor INNER JOIN sumd ON factor.factorID=model.factorID where factorNer='$name'");
while($record = @mysql_fetch_array($result)){
echo '<option value="'.$record['factorID'].'">'.$record['modelNer'].'</option>';
}
}
?>