TOPIC:

DB query in field Actionscript 1 month 11 hours ago #250117

  • Topic Author
  • dgurevich79
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 10
  • Thanks: 0
Hello,

I'm trying to make DB query based on field value, aka (in the user_id field Actionscript):
function ff_user_id_action(element, action)
{
switch (action) {
  case 'change':
    $this->execPieceByName('ff_InitLib'); //Include BreezingForms Library
    $db = JFactory::getDBO();//Get Database Object
    $user_id=ff_getElementByName('user_id').value; //Get user_id from form field
    $query='SELECT id FROM my_table WHERE userid="$user_id"';
    //
    // Here is a Query code...
    //
    ff_getElementByName('first_name').value=$fname;//Update user first name from DB query
    break;
  default:;
  } // switch
} // ff_user_id_action

Could you please advise the correct Query code to implement this requirement in the field custom Actionscript? Can't get it work...

Thanks!

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

DB query in field Actionscript 1 month 33 minutes ago #250124

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 2267
  • Karma: 3
  • Thanks: 210
Hi,

sorry, but you mixed php and javascript.
In actionscript you need to add javascript.

E.g. if you want to populate field from database ( then in your form->Advanced->More options->Form pieces->Before form->check Custom and put this:
$this->execPieceByName('ff_InitLib'); //Include BreezingForms Library
$db = JFactory::getDBO();//Get Database Object
$user = &JFactory::getUser();//Get user Object
 
//Create your own query 
$db->setQuery('Select name From #__users Where id='.$user->id); 
 
$result = $db->loadResult(); //load the result from the query
ff_setValue('ElementName', $result); // populate the value in the form. Change ElementName to the real name of your element


If you want to populate values from the logged in user, you can do this much more quickly by adding the following code directly into the value field of a text element (you do not need any Before Form Piece):
-for userid
<?php $user = JFactory::getUser(); return "$user->id"; ?>
-for name
<?php $user = JFactory::getUser(); return "$user->name"; ?>

Hope this helps

Regards,
Tihana

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

Last edit: Post by tihana.krivic.

DB query in field Actionscript 4 weeks 2 days ago #250129

  • Topic Author
  • dgurevich79
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 10
  • Thanks: 0
Thanks for your update.

However, this is not what I want to achieve. My scenario is to update form's 2nd field (say, user phone number) according to username which was entered in form's 1st field (say, user_id), dynamically.

Is it possible to achieve?

Thanks!

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

DB query in field Actionscript 4 weeks 2 days ago #250130

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 2267
  • Karma: 3
  • Thanks: 210
Hi,

for this you can use ajax and php file:
crosstec.org/en/forums/15-usage/99554-po...-from-db.html#115924

Also, here is an example for city, country.
It shows country based on city.
crosstec.org/en/forums/15-usage/89702-se...html?start=36#204027

I hope I didn't confuse you.
If you need more help, let me know

Regards,
Tihana

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

DB query in field Actionscript 4 weeks 2 days ago #250157

  • Topic Author
  • dgurevich79
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 10
  • Thanks: 0
Thanks a lot, will evaluate it :-)

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

  • Page:
  • 1
Moderators: ForumSupport
Time to create page: 0.050 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!