Hello,
In my php codes, I have a dropdown like this:
<select>
<option value="0">Cat A</option>
<option value="1">Cat B</option>
<option value="2">Cat C</option>
<option value="3">Cat D</option>
</select>
I am hoping to replace it with jqxDropDownList.
I hope we can create some sort of array in PHP, pass it to the jqxDropDownList through the “source” to create such dropdown. But so far, I have no luck.
If the “value” and the “option label” are the same, it will work with something like this:
// php
$data['opt_list'] = array('','Cat A','Cat B','Cat C','Cat D');
// javascript
<div id='my_dropdown'></div>
<script type="text/javascript">
$(document).ready(function () {
$("#my_dropdown").jqxDropDownList(
{ source: <?=json_encode($opt_list)?>,
selectedIndex: 2,
width: '200px',
height: '25px',
theme: 'darkblue' });
</script>
However, if the “value” and “option labels” are different, I can’t figure out what to pass to “source” to get it to work.
Any suggestion? Or other jqwidget components I should look into?
Thank you.