• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
form_dropdown

#1
[eluser]stoat[/eluser]
I seem to be using the dropdown function incorrectly... and 36 hours later I thought I'd ask the experts...
If I use "traditional" php like this

<SELECT NAME="officelist" id="oid">
&lt;?php foreach($t3 as $cc):?&gt;
<option value="&lt;?php echo $cc['oid'] ?&gt;">&lt;?php echo $cc['officename'] ?&gt;
&lt;?php endforeach;?&gt;
</SELECT>

I get the results I'm hoping for...
If I use the form_dropdown shown below, I get the correct number of rows... but the word "Array" instead of the Array value.

echo form_dropdown('officename', $t3,'0',$js);

I feel I'm missing the point somewhere... ;-) any pointers would be very gratefully received!

#2
[eluser]Bogdan Tanase[/eluser]
If I remember correctly the array you pass to form_dropdown needs to looks smth like this:

Code:
$t3=array('key1'=>'value1', 'key2'=>'value2', ... );

your code looks like is a multidimensional array:
Code:
$t3=array(0=>array('oid'=>'some_value', 'officename'=>'some_value'),
          1=>array('oid'=>'some_value', 'officename'=>'some_value'), ... );

so it won't work with form_dropdown

#3
[eluser]stoat[/eluser]
Thanks Bogdan... that makes perfect sense... so handbuild is necessary in this instance... I'll get on to it :-)


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.