Forums

[SOLVED] Can't see dropdown values...?

Ritchie 02 Nov, 2011
hi there,

I use chronoforms v4. In a customcode element i have this:

<select size="1" type="select" name="productenlijst">
<option value="">-------- producten --------</option>
<?php
$db =& JFactory::getDBO();
$query = "SELECT * FROM lw0bd_faqbook_items";
$db->setQuery( $query );
$option = $db->loadObjectList();
foreach($option AS $o)
 {
  $option  = $debiteur->deb_snellenaam;
   echo "<option value='" . $o->title . "'>". $option ."</option>";
  }
?>
</select>


In the form output i see this (printscreen). What goes wrong?? I't seems that it can find the data but the output becomes invisible?
[attachment=0]prod-output.png[/attachment]
GreyHead 02 Nov, 2011
Hi Ritchie,

Please check this line - I'm pretty sure you don't want $option in there
echo "<option value='" . $o->title . "'>". $option ."</option>";

Bob
Ritchie 02 Nov, 2011
Thnx..😀 thats it.

It has to be:

<select size="1" type="select" name="productenlijst">
<option value="">-------- producten --------</option>
<?php
$db =& JFactory::getDBO();
$query = "SELECT * FROM lw0bd_faqbook_items";
$db->setQuery( $query );
$option = $db->loadObjectList();
foreach($option AS $o)
 {
  $option  = $o->title;
   echo "<option value='" . $o->title . "'>". $option ."</option>";
  }
?>
</select>


it works now :mrgreen: 😀 🤣
GreyHead 02 Nov, 2011
Hi Ritchie,

Looks as though you re-posted the un-fixed version of the code.

Bob
Ritchie 03 Nov, 2011

Hi Ritchie,

Looks as though you re-posted the un-fixed version of the code.

Bob



Hi Bob,

No it's slighty different:
The wrong code
foreach($option AS $o)
{
 $option  = $debiteur->deb_snellenaam;
   echo "<option value='" . $o->title . "'>". $option ."</option>";
  }
?>


The good code
foreach($option AS $o)
{
 $option  = $o->title;
   echo "<option value='" . $o->title . "'>". $option ."</option>";
  }
?>


$option = $o->title; instead of $option = $debiteur->deb_snellenaam;

This works for me anyway... 😀
GreyHead 03 Nov, 2011
Hi Ritchie,

Ah, I missed that, looks risky to me though as you are redefining $option in the middle of a loop that uses it. This might be neater
foreach ( $option as $o) {
   echo "<option value='{$o->title}' >{$o->title}</option>";
}
?>

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