July 30, 2010, 10:13:30 am *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Common questions answered here !
 
   Home   Help Search Login Register  
Pages: 1 [2]   Go Down
  Print  
Author Topic: Displaying data from a database when a drop down entry is selected  (Read 12974 times)
KaiLg
Jr. Member
**
Offline Offline

Posts: 63


« Reply #15 on: July 24, 2006, 01:23:48 pm »

ok I solved the problem:

Select List (action script)
changed to:
Code:
function ff_sort_action(element, action)
{
    switch (action) {
        case 'select':
        case 'change':
            ff_redirectParent(
            'index.php?option=com_facileforms&Itemid=157'+
            '&ff_page=2'+
            '&ff_border=0'+
            '&ff_param_sort='+escape(element.value)
            )       
     break;
        default:;
 } // switch
} // ff_sort_action
Logged
virulazo
Newbie

Offline Offline

Posts: 7


« Reply #16 on: August 01, 2006, 11:36:44 pm »

Hi guys...hope you don't mind i get into the thread.

Does this code that you are discussing here help me do the following?

- a form with 2 dropdowns:

First one loads from the beginning all the countries of the world from a database table(230 records).

Second drop-down depending on country that user selects in drop-down 1, queries the database for the cities for that country and fills the second drop-down with those options. All the cities of the world are more than 6000, so it's logical i want to only query for the cities of the selected country, right?

So does this code help me do that or is there a better way to accomplish this?


By the way i'll also have to find a way to insert later the country and city chosen in the Joomla CB user's registration, ideally right when the user is registering  Huh? but that is another problem.

Thanks for any help  Smiley
NiCo



Logged
boldee
Administrator
Living Legend
*****
Offline Offline

Posts: 1352



« Reply #17 on: August 02, 2006, 12:10:13 pm »

If you are still looking at the basic form with no modifications of your own then you will have to be logged in as it uses the user table, this is a default of mambo/joomla i think it may change if you use your own table.
Logged

Nick

Please read the forum rules first!
Please do not use PM for generic questions!
Please visit...
Protean MMO
boldee
Administrator
Living Legend
*****
Offline Offline

Posts: 1352



« Reply #18 on: August 02, 2006, 12:11:33 pm »

Have you looked at the country select in the ff sample package?
Logged

Nick

Please read the forum rules first!
Please do not use PM for generic questions!
Please visit...
Protean MMO
virulazo
Newbie

Offline Offline

Posts: 7


« Reply #19 on: August 02, 2006, 05:33:22 pm »

Oh sorry, yes...i should have mentioned it. I have looked and try to use/modify the country select sample but the main difference is that that sample form has all the options hardcoded in arrays inside the form scripts.

I want to make one first query to fill the first drop-down with the countries(no problem with that), and then, depending on the country selected, query the database again to get only the cities for that country and fill the second combo-box. I asume this has to go in the Action > Change script, but i am not sure how to reference the country selected from within PHP.

And of course, i will need to then submit the form, close it and pass the country and city selected, to 2 respective fields in the CB registration page. Can this be done?

Cheers, and thank you very much for your time  Smiley
Logged
boldee
Administrator
Living Legend
*****
Offline Offline

Posts: 1352



« Reply #20 on: August 02, 2006, 08:32:39 pm »

First its important to remember the differences between scripts and pieces.

Leave it with me ill make you some sample code.
Logged

Nick

Please read the forum rules first!
Please do not use PM for generic questions!
Please visit...
Protean MMO
boldee
Administrator
Living Legend
*****
Offline Offline

Posts: 1352



« Reply #21 on: August 02, 2006, 09:19:29 pm »

Ive tested this so i know it works
Code:
    switch (action) {
        case 'select':
        case 'change':
            ff_redirectParent(
            'index.php?option=com_facileforms'+
            '&ff_name=your_form_name'+
            '&ff_page=your_page'+
            '&ff_border=0'+
            '&ff_param_sort='+escape(element.value)
            )       
     break;
        default:;
 } // switch
Place the code above in the custom action script of your first select list, redirects to the appropriate page and passes the value of your first select list.

Place the below code into options in your second select list, it picks up the parameter and displays the result by record.
Code:
1;Select user group;none
<?php
/*
  This php code is executed while the page is created.
  It queries the userlist by sql and creates options for the select list.
*/
global $database;

$record=mosGetParam($_REQUEST'ff_param_sort''');

$database->setQuery(
    
"select * from #__your_table ".
    
"WHERE `your_column` LIKE '%$record%'".
    
"ORDER your_column ASC"
);
$rows $database->loadObjectList();

$options '';
if (
$rows)
    foreach (
$rows as $row
        
$options .= "0;$row->your_column;$row->your_column\n";
return 
$options;
?>

Logged

Nick

Please read the forum rules first!
Please do not use PM for generic questions!
Please visit...
Protean MMO
virulazo
Newbie

Offline Offline

Posts: 7


« Reply #22 on: August 03, 2006, 01:09:01 am »

Wonderful!!!

It's exactly what i was needing, plus you made me go and actually read the manual(concerning scripts and pieces).

Thank you!!
 Smiley
Logged
jpjordaan
Newbie

Offline Offline

Posts: 18


« Reply #23 on: August 17, 2006, 04:39:25 pm »

Hello

I jumping in as well, but this post is the nearest to what I would like do.

I have to drop down's on my firts page, both need to be selected.

Then I have a next page/submit button that goes to page 2 where I have my Query List.

At the moment if I choose a option from one of the select list, it directs me to the second page and give me my feedback.

What scripting do I need to put on the button so that is sends the 2 values to my second page?

And how do I change the query script to do this for me.

Here is my current select list script:

Code:
function ff_serviceselect_action(element, action)
{
    switch (action) {
             case 'select':
             case 'change':
                   ff_redirectParent(
                   'index.php?option=com_facileforms'+
                   '&ff_name=PropertySearchUK'+
                   '&ff_page=2'+
                   '&ff_border=0'+
                   '&ff_param_sort1='+escape(element.value)
                   )
            break;
        default:;
    } // switch
} // ff_serviceselect_action

And my query script

Code:
global $database;

$service_txt=mosGetParam($_REQUEST, 'ff_param_sort1', '');
$location_txt=mosGetParam($_REQUEST, 'ff_param_sort2', '');

$database->setQuery(
    "select * from #__property_services ".
    "WHERE `service` LIKE '%$service_txt%' or `location` LIKE '%$location_txt%'"
);
$rows = $database->loadObjectList();

I have been batteling with this for quite a while. Any help would be appriciated.

Thanks

Jan
Logged

If it doesnt make you stronger, it will make you dead.
Pages: 1 [2]   Go Up
  Print  
 
Jump to:  

Powered by SMF © 2001-2006 Lewis Media
| Terms of Use | Privacy | Sitemap |