Form Help

TOPIC:

Populate a dropdown menu from a database table with one blank entry 1 year 1 week ago #266052

  • Topic Author
  • sitavs
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 30
  • Thanks: 0
Hi,
I've followed your guide on populating a dropdown menu from a database table ( crosstec.org/en/support/online-documenta...ct-list-from-db.html ) and it works as expected.

However, this doesn't allow for a blank entry in the dropdown, as there are no blank rows (names, in my case) in the database table. Can you tell me how I can solve this please? The dropdown is not a required field so I need to be able to return a NULL value.

Apologies if this has been covered before.

Thanks,
Simon

Please Log in or Create an account to join the conversation.

Populate a dropdown menu from a database table with one blank entry 1 year 1 week ago #266053

  • Mirec's Avatar
  • Mirec
  • Offline
  • Ultimate Breezer
  • Ultimate Breezer
  • Posts: 3265
  • Karma: 2
  • Thanks: 160
Hi,

give me a little time and I will back to you as soon as possible with answare!

Regards,
Mirko

Please Log in or Create an account to join the conversation.

Populate a dropdown menu from a database table with one blank entry 1 year 1 week ago #266054

  • Mirec's Avatar
  • Mirec
  • Offline
  • Ultimate Breezer
  • Ultimate Breezer
  • Posts: 3265
  • Karma: 2
  • Thanks: 160
Hi,

ok, if I understend well, code should be need like this:
$this->execPieceByName('ff_InitLib'); //Include BreezingForms Library
$db = JFactory::getDBO();//Get Database Object
  
//Create your own query here
$db->setQuery('Select username From #__users '); 
  
$result = $db->loadColumn(); //load the result from the query
$test = "";
for ($i = 0; $i < count($result); $i++)
{
     $test .= "0;;\n 0;".$result[$i].";".$result[$i]."\n";
}
 
function ff_setSelectList($name, $value)
{
     global $ff_processor;
     for ($r = 0; $r < $ff_processor->rowcount; $r++)
     {
          $row =& $ff_processor->rows[$r];
          if ($row->name==$name)
          $row->data2 = $value;
          unset($row);
     } // for
} // ff_setSelectList
 
ff_setSelectList('nameofelement', $test);

Let me know the result!

Regards,
Mirko
The following user(s) said Thank You: sitavs

Please Log in or Create an account to join the conversation.

Last edit: Post by Mirec.

Populate a dropdown menu from a database table with one blank entry 1 year 1 week ago #266063

  • Topic Author
  • sitavs
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 30
  • Thanks: 0
Thanks very much. I also had a reply from Tihana with a variation on this:
$this->execPieceByName('ff_InitLib'); //Include BreezingForms Library
$db = JFactory::getDBO();//Get Database Object
  
//Create your own query here
$db->setQuery('Select username From #__users '); 


  
$result = $db->loadColumn(); //load the result from the query
$test ="0;Please Select;\n";
for ($i = 0; $i < count($result); $i++)
{
     $test .= "0;".$result[$i].";".$result[$i]."\n";
}
 
function ff_setSelectList($name, $value)
{
     global $ff_processor;
     for ($r = 0; $r < $ff_processor->rowcount; $r++)
     {
          $row =& $ff_processor->rows[$r];
          if ($row->name==$name)
          $row->data2 = $value;
          unset($row);
     } // for
} // ff_setSelectList
 
ff_setSelectList('select1', $test);

Please Log in or Create an account to join the conversation.

Populate a dropdown menu from a database table with one blank entry 1 year 1 week ago #266064

  • Mirec's Avatar
  • Mirec
  • Offline
  • Ultimate Breezer
  • Ultimate Breezer
  • Posts: 3265
  • Karma: 2
  • Thanks: 160
Hi,


super! :)

If you need more help, let know us! :)

Regards,
Mirko

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Moderators: ForumSupport
Time to create page: 0.049 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!