javascript - populating a dropdown box, based on the selection of another dropdown box using php, mqsql and ajax -
i trying populate drop down box, based on selection drop down box. here have php code:
<form id="inventory" method="post" action=""> <fieldset> <label for="area" >select shelf area</label> <select id="area" name="area"> <option value=""></option> <?php $area = $conn->query(" select substring_index(location, ' ', 1) area location group substring_index(location, ' ', 1)"); while ($row = $area->fetch_assoc()) { echo '<option value="' . $row['area'] . '" >' . $row['area'] . '</option>'; } > </select><br/> </fieldset> </form> when run query, fine, need take results of , use populate drop down box ( <'value previous drop down '>) here:
echo "<label for='location' id='label'>select location:</label>"; echo "<select id='location' name='location'>"; echo "<option value=''>--select location--</option>"; $query = "select location_id, location location location '<value previous drop down box>' order location"; $result = $conn->query($query); while ($row = $result->fetch_assoc()) { echo '<option value="' . $row['location'] . '" >' . $row['location'] . '</option>'; } any thoughts? jim
may using substring_index function in wrong way.
in 1st select might not getting output or may blank rows.
according website -
substring_index(str,delim,count)
returns substring string str before count occurrences of delimiter delim. if count positive, left of final delimiter (counting left) returned. if count negative, right of final delimiter (counting right) returned. substring_index() performs case-sensitive match when searching delim.
Comments
Post a Comment