TOPIC:

Populate select-list from DB using user data 10 years 2 months ago #13138

  • Topic Author
  • dack
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 5
  • Thanks: 0
Hi,

I'm trying to populate a select-list filtered by data entered by the user. The error i'm gettijg in the code below is 'Call to undefined function getElementById'.

I've tried using ff_getElementByName but same error.

Any ideas anyone please?
<?php
/*
This php code is executed while the page is created.
It queries the userlist by sql and creates options for the select list.
*/
$users = ff_select("select name, username from #__users");
$options = '';
if ($users)
foreach ($users as $user)
if ($user->name == document.getElementById('User').value)
$options .= "0;$user->name;$user->username\n";
return $options;
?>

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

Re:Populate select-list from DB using user data 10 years 2 months ago #13242

  • Pete550
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 10
  • Thanks: 0
in Beginn Formular:
global $userlist;
$this->execPieceByName('ff_InitLib');

$strquery = "SELECT `name`, `username ` FROM #__users ".    
            "ORDER BY name; ";

$rows = ff_select( $strquery );

$userlist="0;Username;0\n";
if (Count($rows))
{
   foreach($rows as $record)
   {
      $userlist.="0;$record->name; $record->username\n";
   }
}


in your select List under options:
<?php
  global $userlist;
  return $userlist;
?>

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

Re: Populate select-list from DB using user data 9 years 11 months ago #14945

  • facommunications.com
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 9
  • Thanks: 0
Hi Peter,

Could you please help me here.

I'm trying to populate a select list with content that I retrieve from database #__categories.
I have this piece of code that is in "Before Form" option of my form.
// load the standard form creation utilities
$this->execPieceByName('ff_InitLib');

//set globals
global $record;

//set value of id
$rid = ff_getParam('ff_param_rid');

//load existing data
global $record;

//query db
$rows = ff_select("select `title` from `#__categories` where published=1");

$categorie="1;Veuillez choisir un;\n";
   
   if (Count($rows))
{
   foreach($rows as $record)
   {
      $categorie.="0;$record->title; $record->title\n";
   }
}

In my "Select List" Categorie, in "Advanced" tab then "Initscript" I selected "Custom" and have put this code
<?php
  global $categorie;
  return $categorie;
?>

Whoever in my form my "Categorie" select list is empty. Do you know what is not working in what I'm doing? I'm not even sure what I'm doing is the right way.

Thank you very much in advance for your help.

Helio

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

Re: Populate select-list from DB using user data 9 years 11 months ago #14946

  • Pete550
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 10
  • Thanks: 0
Hi Helio

make a new select list and under options are something like:
1;Select Color;''
0;Red;red
0;Green;green
0;Blue;blue

delete this complete an copy in:
<?php
  global $categorie;
  return $categorie;
?>

thats all.



You build your options here in Before Form:
$categorie.="0;$record->title; $record->title\n";
example $categorie result:
0;Helio;Helio
0;admin;admin

thats the same like
0;Red;red
0;Green;green


greetings

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

Re: Populate select-list from DB using user data 9 years 11 months ago #14948

  • facommunications.com
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 9
  • Thanks: 0
Hi Peter,

Thank you for your fast reply.

This is what I did, I created a select list element and deleted default content:
0;Title 1;value1
0;Title 2;value2
0;Title 3;value3


But in select list elements I don't have "Options", what I have is, under "Advanced" tab:
Element Options where I have:
Hide label
Mailback
Logging
Order Number
Tab index
Turn off
Title position

Then I have Initscript where I have:
Type: None Library Custom
When I select "Custom" I get a field where I can put content.
I also have two options: Form Entry and Page Entry
I can select either Form Entry or Page Entry, none or both.
In the field I've put this content:
<?php
  global $categorie;
  return $categorie;
?>
And finally I have Actionscript where I also have
Type: None Library Custom

So should the code
<?php
  global $categorie;
  return $categorie;
?>
be in Initscript as I did or should it be somewhere else?

Thank you

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

Re: Populate select-list from DB using user data 9 years 11 months ago #14952

  • Pete550
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 10
  • Thanks: 0
do you work with easy mode?
the instructions are for classic mode

i have to take a look at easy mode.
never worked with easy mode before

but php code dont work in javascript.
Actionscript, Initscript are for JS

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

  • Page:
  • 1
  • 2
Moderators: ForumSupport
Time to create page: 0.052 seconds

July Sale!

Discounts for all of our extensions + support. Ending July 31st!

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!