How can I change a value in an array?

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

Was this solution helpful to you?

Find solution

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.