How to solve if i select one Value form dropdown. Biside I have another drop down and its values should be auto Updated According to Option I have selected from first dropdown ?
Asked
Active
Viewed 1,116 times
-2
-
3Have you written some code or expecting some one will write for you – M A SIDDIQUI Jan 12 '17 at 10:28
-
1What are you trying to explain, be more specific – Mayank Pandeyz Jan 12 '17 at 10:28
-
make an ajax call based on the first selected option to get the data for the other select. – Suchit kumar Jan 12 '17 at 10:31
-
Possible duplicate of [Dependent Dropdowns (Linked Selects) with single class (no other selectors)](http://stackoverflow.com/questions/2870579/dependent-dropdowns-linked-selects-with-single-class-no-other-selectors) – ᴄʀᴏᴢᴇᴛ Jan 12 '17 at 10:34
1 Answers
0
you can try to generate a lookup table whenever you create a drop-down list:
function createDropdown(&$ddlLookup) {
echo '<select multiple name="items[]">';
try {
$items = mysql_query("SELECT item_id,item_type FROM items");
while ($row = mysql_fetch_assoc($items)) {
echo '<option value="'.$row['item_type'].'"';
echo '>'. $row['item_type'] . '</option>'."\n";
$ddlLookup[$item_type] = $item_id;
}
}
catch(PDOException $e) {
echo 'No results';
}
echo '</select>';
}
Then whenever you need the id for a given description you use that table(array) to get it:
$mainDropdownLUT = array();
createDropdown($mainDropdownLUT);
var_dump($mainDropdownLUT['testCow']);
-> 734
Also, if you need to pass it to another page it can be serialized and added to a hidden field.
$mainDropdownLUT = serialize($mainDropdownLUT);
"<input type="hidden" value =\"$mainDropdownLUT\">"
-------------------------**OTHER PAGE **--------------
$mainDropdownLUT = unserialize($mainDropdownLUT);

Abi
- 724
- 6
- 22