Get value of second dropdown, based on first?
-
Basically, what I'm trying to accomplish is when someone clicks the first html dropdown `id="FirstDD"`, based on the `option` chosen the second dropdown `id="SecDD"` would populate with the fields that correlate to `FirstDD` dropdowns choice. Triggering this all is ajax to do the initial call and php to handle from there in `subcategories.php`. Currently, what is happening is: i selected the first dropdown, but nothing gets populated in `SecDD` **JS/AJAX:** <script type="text/javascript"> $(document).ready(function(){ $("#FirstDD").change(function(){ $('#SecDD').load('inc/subcategories.php… }); }); </script> **HTML** <select style="width:300px;" id="FirstDD" name="userListingCategory"> <!--onchange="$('#SecDD').load('inc/… <option disabled="disabled">Category...</option> <?php while($row = $sth2->fetch(PDO::FETCH_ASSOC)) {echo "<option value=". $categoryID . ">" .$row['catName']."</option>";} unset($sth2); ?> </select> <select style="width:340px;" id="SecDD" name="userListingSCategory" style="display:none"> <?php require_once('inc/subcategories.php'); ?> </div> </select> **Subcategories.php** <?php require_once('db/dbc.php'); #GET SELECT sub-category names $pdo3 = new PDO($h1, $u, $p); $pdo3->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); $sth3 = $pdo3->prepare(" SELECT scatID, scatName FROM Category C, SubCategory SC WHERE C.catID = SC.catID ;"); $sth3->execute(array()); ?> <option disabled="disabled">Sub-Category...</opt… <?php #Get subcats while($row = $sth3->fetch(PDO::FETCH_ASSOC)) {echo "<option value=". $row['scatID'] . ">" .$row['scatName']."</option>";} unset($sth3); ?>
-
Answer:
AJAX is bad, and you are a bad person for using it.
adfafsdd... at Yahoo! Answers Visit the source
Related Q & A:
- Does Mathematica use first-order or second-order unification?Best solution by Mathematica
- How to set value in the dropdown from a JSON data list?Best solution by Stack Overflow
- How to find the column name of the first column with a null value?Best solution by Stack Overflow
- What all-inclusive resort in Mexico has the best value and experiences for first timers?Best solution by Yahoo! Answers
- What are good ways to get the "Last Second Bid" on eBay successfully?Best solution by ebay.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.