Welcome Guest, Not a member yet? Register   Sign In
How to change order of form_dropdown?
#1

[eluser]suntrop[/eluser]
I get a list of names from my DB and want to show it in a form dropdown. But unfortunately the dropdown shows a wrong order.
CI sorts the <select> by the value of its <option>, in my case the DB id. But I need it to sort it by the text inside the <option>.

Code:
<select name="name">
  <option value="0"></option>
  <option value="1">Chris</option>
  <option value="2">Bill</option>
  <option value="3">Andy</option>
  <option value="4">Zed</option>
</select>

… I need:
Code:
<select name="name">
  <option value="0"></option>
  <option value="3">Andy</option>
  <option value="2">Bill</option>
  <option value="1">Chris</option>
  <option value="4">Zed</option>
</select>

Is there any way to change the order of from_dropdown?




Theme © iAndrew 2016 - Forum software by © MyBB