mysql database query in element (select from list)

  • Posts: 2348
  • Karma: 85
  • Thank you received: 315

mihaela replied the topic: mysql database query in element (select from list)

Hello,

The value.php file seems fine.
Please send me backend login info to your site to mihaela.kobovac@crosstec.org so I can take a look at your form and try to figure out why it is not working.

In the email write the name of form that I should look at.

Regards,

Mihaela
#232350
  • mlangamer
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 24
  • Thank you received: 0

mlangamer replied the topic: mysql database query in element (select from list)

Just sent
#232355
  • Posts: 2348
  • Karma: 85
  • Thank you received: 315

mihaela replied the topic: mysql database query in element (select from list)

Hello,

Thank you for the credentials.

I will take a look at this and get back to you as soon as possible.

Regards,

Mihaela
#232357
  • Posts: 2348
  • Karma: 85
  • Thank you received: 315

mihaela replied the topic: mysql database query in element (select from list)

Hello,

I've changed the Actionscript and now it is working but only for some select list options or it might be that for some values there aren't any Vagas disponíveis.
Please test the form yourself and let me know whether it returns the correct values.

Also, check whether you have entered the correct values in select list.

I've used the following script:
function ff_tipo_vaga_action(element, action)
{
    switch (action) {
        case 'change':
            jQuery.ajax({
                type: "POST",
                url: "http://www.sistemas.ti.educacaoluziania.go.gov.br/consulta2.php",
                data: { tipo_vaga: element.value },    
                success: function(data) {
                var obj = JSON.parse(data);
                        jQuery('#ff_elem381').empty();
                       var arr = obj;
                       jQuery('#ff_elem381').append(jQuery('<option>', {
                                value: '',
                                text: 'Choose option'
                            }));
                       for (var i = 0; i < arr.length; i++) { 
                           console.log(arr[i]);
                           jQuery('#ff_elem381').append(jQuery('<option>', {
                                value: arr[i],
                                text: arr[i]
                            })); 
                        }
                }      
            });
            break;
        default:;
    } // switch
} // ff_tipo_vaga_action

NOTE: I see that you are using ajax request on "consulta2.php" file, not "value.php". I assume that you've decided to change the file's name, but I wanted to note that just in case.

Regards,

Mihaela
#232361
  • mlangamer
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 24
  • Thank you received: 0

mlangamer replied the topic: mysql database query in element (select from list)

Mihaela, it's working perfectly!
Thank you very much!
I know this help is helping other users as well.
Please tell me what was wrong?

I still need to make 2 adjustments that are, when selected
• Bring the contents of the QUANTIDADE_DE_VAGAS column to the VAGA element
• Bring the contents of the EMAIL_ESCOLA column to the EMAILESCOLA element

And if possible show me how I can add to the VAGAS DISPONÍVEIS result in the selection
In addition to the school, add another column together that would be QUANTIDADE_DE_VAGAS

Example:
EVA MARRA ROCHA - 20 VAGAS

Thank you in advance.
#232379
  • Posts: 2348
  • Karma: 85
  • Thank you received: 315

mihaela replied the topic: mysql database query in element (select from list)

Hello,

I'm really glad that this is working as you wanted.

Actually, I've pasted my script in your Actionscript and adjusted it to your form so I am not sure where was the error in your script.
Therefore I have posted the working script in my previous post so other users can see which script worked in the end.
Thank you for caring about helping the others.

To add QUANTIDADE_DE_VAGAS to the VAGAS DISPONÍVEIS options in select list follow these steps:
1) You have to change the consulta2.php file.
Replace this part of code:
$db->setQuery('SELECT `escola` FROM `vagas` WHERE quantidade_de_vagas > 0 AND serie ='.$db->quote($judgePick)); 
$result = $db->loadColumn();
with this code:
$db->setQuery('SELECT `escola`, `quantidade_de_vagas` FROM `vagas` WHERE quantidade_de_vagas > 0 AND serie ='.$db->quote($judgePick)); 
$result = $db->loadRowList();

2) In Actionscript of tipo_vaga element change this part of code:
 for (var i = 0; i < arr.length; i++) { 
                           jQuery('#ff_elem381').append(jQuery('<option>', {
                                value: arr[i],
                                text: arr[i]
                            })); 
                        }
with this piece of code:
 for (var i = 0; i < arr.length; i++) { 
                           jQuery('#ff_elem381').append(jQuery('<option>', {
                                value: arr[i][0],
                                text: arr[i][0] + ' - ' + arr[i][1] + ' VAGAS'
                            })); 
                        }

Regarding the other part, you would like to fill fields vaga and emailescola depending on which 'escola' is selected in the other Vagas disponíveis select list, is that correct?

Regards,

Mihaela
#232402
The following user(s) said Thank You: mlangamer
Moderators: ForumSupporttomeperica
Time to create page: 0.074 seconds

Summer Sale!

50% discount on all of our extension subscription plans & templates!

Get Your Subscription Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99 for just 49! (Summer Sale)

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

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!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here