1 Replies - 156 Views - Last Post: 10 May 2021 - 01:55 AM

#1 chrisjchrisj   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 150
  • Joined: 04-February 19

Help display 2nd Dropdown list when selection is made (from first drop

Posted 08 May 2021 - 02:00 PM

I am trying to modify a existing web script's Upload Form where, currently you choose a Category...etc. and Submit. When a Category is chosen, I'd like another dropdown list of choices to display. Here is the code currently:

<div class="form-group">
<label class="col-md-12" for="category_id">{{LANG category}}</label>
<div class="col-md-12">
<select name="category_id" id="category_id" class="form-control">
<?php foreach($pt->categories as $key => $category) {?>
<option value="<?php echo $key?>"><?php echo $category?></option>
<?php } ?>
</select>
</div>
</div>



Any guidance/assistance with this appreciated.

Is This A Good Question/Topic? 0
  • +

Replies To: Help display 2nd Dropdown list when selection is made (from first drop

#2 Dormilich   User is offline

  • 痛覚残留
  • member icon

Reputation: 4297
  • View blog
  • Posts: 13,643
  • Joined: 08-June 10

Re: Help display 2nd Dropdown list when selection is made (from first drop

Posted 10 May 2021 - 01:55 AM

You have 3 options:
- submit the (incomplete) form to make PHP print the second dropdown
- use AJAX to populate the second dropdown
- use Javascript to filter the existing (complete) values in the second dropdown to match the selection of the first dropdown
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1