TOPIC:

Database Access in Action Script 2 months 1 week ago #257102

  • Topic Author
  • fsv_sarstedt
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 9
  • Thanks: 0
Hello,
I am trying to achieve the following:
The User enters a date in a Textfield. The Textfield has an action Script, which triggers on "Change". The Action script accesses a table in the Joomla Database and selects the time coloum from all rows where coloum "date" matches the user date. Does anybody has an idea how to manage this?

Thanks for your suggestions,
Manuel

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

Database Access in Action Script 2 months 1 week ago #257105

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

I have a question:
user enters date in textfields, then you want to find all data from database that correspond to enters date by user and show that in another element?

Regards,
Tihana

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

Database Access in Action Script 2 months 1 week ago #257107

  • Topic Author
  • fsv_sarstedt
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 9
  • Thanks: 0
That is right, if the user enter e.g. 10.04.2021 i want my radio buttons to show the available times from the database for this date.

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

Database Access in Action Script 2 months 1 week ago #257111

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

to achieve what you want, you have to write an Ajax query in the Actionscript of the textfield.

Here is a small example for the code of php and ajax:
crosstec.org/en/forums/15-usage/99554-po...-from-db.html#115924

Please test it, if you get in stuck I will help you :)

Regards,
Tihana

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

Database Access in Action Script 2 months 1 week ago #257140

  • Topic Author
  • fsv_sarstedt
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 9
  • Thanks: 0
Thank you for your answer, I tried some things based on the answers on your linked page.
Here is my current code:

The Action Script of my Date Text Field:
function ff_customcalendar_action(element, action){
    switch (action) {
        case 'change':
            jQuery.ajax({
                type: "POST",
                url: "<?php return JURI::root(true ); ?>/php/available_dates.php",
                data: {code: ff_getElementByName('customcalendar').value},
                success: function(msg){
                    console.log("MSG" + msg)
                } //function_msg
            }); //ajax
        break;
        default:;
    } // switch
} // ff_customcalendar_action

The file available_dates.php:
<?php

define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) );
define( 'DS', DIRECTORY_SEPARATOR );

/* Required Files */
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

/* To use Joomla's Database Class */
require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'factory.php' );

/* Create the Application */
$mainframe =& JFactory::getApplication('site');

$code=$_POST['code'];   				// the value posted from the AJAX request above
//-----process DB query-------

$database = $db = JFactory::getDBO();

$sql="SELECT time FROM fsv_available_dates WHERE date='2021-04-10'";

$database->setQuery($sql);

//----------------------------

if($back=$database->loadAssoc()){
    echo "Test";
} else {
    echo "error";
} 
               
?>

So at this point I am expecting to get either the Message "Test" or "error" logged to the console of the browser. But the only thing I get is the following error without furtehr details:
POST https://www.myurl.de/php/available_dates.php 500
send @ jquery.min.js?012e339d7b71babbc6aaf56ea682455a:2
ajax @ jquery.min.js?012e339d7b71babbc6aaf56ea682455a:2
ff_customcalendar_action @ testform:549
onchange @ testform:559
a @ calendar-setup.js?012e339d7b71babbc6aaf56ea682455a:1
Calendar.callHandler @ calendar.js?012e339d7b71babbc6aaf56ea682455a:1
Calendar.cellClick @ calendar.js?012e339d7b71babbc6aaf56ea682455a:1
Calendar.tableMouseUp @ calendar.js?012e339d7b71babbc6aaf56ea682455a:1

Can you tell me what I have to change?

Thanks!

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

Database Access in Action Script 2 months 1 week ago #257142

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

could you please send me your form, your php file (available_dates.php), and database?

For exporting form go to BF->Configuration->Create Package->from Form Selection select only this one form. Zip xml file, php file and database and post it here

Regards,
Tihana

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

Moderators: ForumSupport
Time to create page: 0.051 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!