Answer the question
In order to leave comments, you need to log in
How to make a dependent select list based on the data inside?
How can I make a dependent select list based on the select data?
I wrote the first part of the list, but the second part does not want to be shown through value, I don't understand how to write php code correctly.
<?php $biolink_pages = require APP_PATH . 'includes/biolink_pages.php'; ?>
<div class="form-group">
<label for="settings_pages"><i class="fa fa-fw fa-user fa-sm mr-1"></i> <?= language()->link->settings->font ?></label>
<select id="settings_page_type" name="page_type" class="form-control">
<?php foreach($biolink_pages as $key => $value): ?>
<option value="<?= $key ?>" <?= $data->link->settings->page_type == $key ? 'selected="selected"' : null?>><?= $key ?></option>
<?php endforeach ?>
</select>
</div>
<?php
return [
'businesses' => [
],
'community_organization' => [
],
'interest' => [
],
'media' => [
],
'public_figure' => [
'actor',
'artist',
'athlete',
'author',
'band',
'blogger',
'chef',
'comedian',
'dancer',
'designer',
'fashion-designer',
'digital-creator',
'editor',
'entrepreneur',
'fashion model',
'film-director',
'fitness model',
'gamer',
'journalist',
'motivational-speaker',
'musician',
'musician-band',
'news personality',
'orchestra',
'producer',
'scientist',
'spiritual-leader',
'sports-promoter',
'talent-agent',
'video-creator',
'writer'
],
];
<div id="" class="form-group">
<label for="settings_pages"><i class="fa fa-fw fa-user fa-sm mr-1"></i> <?= language()->link->settings->font ?></label>
<select id="settings_page_category" name="page_category" class="form-control">
<?php foreach($biolink_pages['public_figure'] as $page_category): ?>
<option value="<?= $page_category ?>" <?= $data->link->settings->page_category == $page_category ? 'selected="selected"' : null?>><?= $page_category ?></option>
<?php endforeach ?>
</select>
</div>
Answer the question
In order to leave comments, you need to log in
here is a piece of code that is displayed, but does not write the valuePerhaps it does not lie in the same form as the first select?
+ is not tied to the choice of the firstHow did you try to bind it? You stupidly brought one more select to the page, didn't you?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question