Forums

Dropdown list in Custom Code / Custom Element

Rolfo 12 Oct, 2011
Hi, (v4 & 1.7.1)

I made a drop down list in a Custom Code action in the 'on record found' section which works fine, but show up (offcourse) above the form. How can I get the output put into a custom element?
<select size="1" title="" type="select" name="debiteurenlijst">
<option value="">- Debiteurenlijst -</option>
<?php
   foreach($form->data['modelid'] as $detail)
{
echo "<option value='" .$detail['id_userinfo_deb'] ."'>" .$detail['deb_snellenaam'] ."</option>";
}
?>
</select>

I also tried to declare an array in the Custom Code box and use the foreach in an element. But with no result sofar. Or should I make the database query and everything in the Custom Element?

Greetings, Rolf
Rolfo 12 Oct, 2011
Using a custom element with the php including the query is a solution. I suppose it is the best way to do it like that. If not I would like some comment.

Bye, Rolf

<select size="1" type="select" name="debiteurenlijst">
    <option value="">- debiteurenlijst -</option>
    <?php
    $db =& JFactory::getDBO();
    $query = "SELECT * FROM #__tablename";
    $db->setQuery( $query );
    $debiteuren = $db->loadObjectList();
    foreach($debiteuren AS $debiteur)
    {
      $option  = $debiteur->deb_snellenaam;
      echo "<option value='" . $debiteur->id_userinfo_deb . "'>" . $option . "</option>";
    }
    ?>
    </select>
GreyHead 15 Oct, 2011
Hi Rolf,

That's how I would do it.

Bob
This topic is locked and no more replies can be posted.