I want to display dynamic dependent dropdown list in CI. I create below dynamic json but I am not understanding how to convert this to php format.
{
"salary": [
{
"id": 0,
"text": 2017,
"data": {},
"children": [
{
"id": 1,
"text": "May"
},
{
"id": 2,
"text": "July"
},
{
"id": 3,
"text": "August"
},
{
"id": 4,
"text": "September"
},
{
"id": 5,
"text": "October"
}
]
}
]
}
Below is my PHP code where I want to implement this code.
If text
= 2017 is same means PAY_YEAR IS SAME then in it will display all months that are in its children
part.it should be displayed in PAY_MONTH part.
Like: in json we can see 2017 is there and in children part 5 months inside it. So, if a user will select 2017 from dropdown then in another dropdown of pay_month all months should come.
<form action="#" method="get" class="form-horizontal">
<div class="control-group" style="float: left;">
<label class="control-label">Select Year</label>
<div class="controls">
<select>
<?php
foreach ($salary as $row) {?>
<option><?php echo $row->PAY_YEAR;}?></option>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label">Select Month</label>
<div class="controls">
<select>
<?php
foreach ($salary as $row) {?>
<option><?php echo $row->PAY_MONTH;}?></option>
</select>
</div>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-success">Search</button>
<button type="submit" class="btn btn-success">Cancel</button>
</div>
</form>
I hope you guys understand me.