This topic is locked
[SOLVED]

 Create multi level drop down list driven by input from previous drop d

12/6/2010 9:43:10 AM
PHPRunner General questions
C
chingupt author

Hi All,
I wanted to explore how the following could be achived via PHP Runner?
Consider an eg: i have a set of Countries offering various PG/UG courses in colleges/universities.
Now i want that user should

  1. First Select Country
  2. Depending on Country, then ask for UG or PG. It is possible that the Country in DB is not offering PG.
  3. Depending on Country and PG, the College/University list should be shown. It is possible that one college might offer PG, but not UG
  4. Then depending on above 3 selections, show list of Courses in Country+UG/PG+College
    How can i achieve this? Is it possible via PHP runner or as i presume, manual coding would be required?
    Your Expert Help is appreciated.
    Problem is:
    Suppose the Table contains records such as
    No Category Course College Country

    1, 'UG', 'BE', 'LEEDS', 'UK',

    2, 'UG', 'BSc', 'LEEDS', 'UK',

    3, 'PG', 'MSc', 'LEEDS', 'UK',

    4, 'PG', 'Msc', 'UCLA', 'UK',
    Now, i will select first Country -> UK
    Then it shows me Course Category as UG/PG
    Suppose i select "PG",
    Then it shows me Colleges as LEEDS.
    Now it will show me BE, Bsc and MSc.
    Here instead i wanted only PG Courses such as Msc to be shown.
    How can this example be achieved?
    Regards

Sergey Kornilov admin 12/6/2010

You can set up these fields as dependent dropdown boxes. For example set up Country as main dropdown and UG/PG as dependent dropdown.
Here is a helpful article:

http://xlinesoft.com/asprunnerpro/docs/lookup_wizard.htm
Here is a tutorial ('How to setup dependent dropdown boxes on Edit/Add pages') showing steps to create it:

http://xlinesoft.com/phprunner/php-database.htm
Also to hide the dependent dropdowns by default and then show them use 'JavaScript Onload event' on the Events tab.

Here is just a sample:

var ctrl = Runner.getControl(pageid, 'Country');
function func() {

if (ctrl.getValue()=='UK'){

document.getElementById("hidediv1").style.display="none";

document.getElementById("hidediv2").style.display="table-row";

}

else{

document.getElementById("hidediv1").style.display="table-row";

document.getElementById("hidediv2").style.display="none";

}

};
ctrl.on('keyup', func);


Then edit HTML code for this page on the Visual Editor tab in HTML mode:

{BEGIN UG_fieldblock}

<TR id=hidediv1 style="PADDING-RIGHT: 3px; PADDING-LEFT: 3px; PADDING-BOTTOM: 3px; PADDING-TOP: 3px">

<TD class=editshade_b style="PADDING-LEFT: 15px" width=150>{$label TableName UG}</TD>

<TD class=editshade_lb style="PADDING-LEFT: 10px" width=250>{$UG_editcontrol}

</TD></TR>

{END UG_fieldblock}

{BEGIN PG_fieldblock}

<TR id=hidediv1 style="PADDING-RIGHT: 3px; PADDING-LEFT: 3px; PADDING-BOTTOM: 3px; PADDING-TOP: 3px">

<TD class=editshade_b style="PADDING-LEFT: 15px" width=150>{$label TableName PG}</TD>

<TD class=editshade_lb style="PADDING-LEFT: 10px" width=250>{$PG_editcontrol}

</TD></TR>

{END PG_fieldblock}
I
indigo 12/6/2010

I doubt this solution will work. PHP Runner cannot do this.
So, you will get first two steps right.

1. First Select Country

2. Depending on Country, then ask for UG or PG. It is possible that the Country in DB is not offering PG.

3. Depending on Country and PG, the College/University list should be shown. It is possible that one college might offer PG, but not UG

4. Then depending on above 3 selections, show list of Courses in Country+UG/PG+College


For Step 3, you can EITHER make it dependant on Country OR PG. It cannot be both.

So, in your example, once you select 'UK' and 'PG', you will get both 'LEEDS' and 'UCLA' as options. (assuming its dependant on 'PG')
Please correct me if I am wrong.

C
chingupt author 12/8/2010

Thanks for replying.
It can be done. As shown in the video.
Since the college is dependent on the selection of country and course category, i will have to create another column in the same table which will concatenate the values of Country and category. Similarly, for course, since it depends on selection of country, category and college, i need another col containing concatenation of country-category-college.
I tried this and it was working. But again i seem to have stuck here.
let me explain:
For e.g. i have this table "course_category_table" and "Student_info" table. Now the table caurse_categorytable has the following cols, Country, Category, College and Course. For these columns i have configured for the user to add, edit, list. In the same table, i also have two other columns, "Country-category" and "country-category-college". I dont expect the user to provide values for these two columns. So i will have to modify the Insert Query for the Add Page and also the Update Query for Editing records.
But how do i do this?
Where do i modify the insert and the update queries?
I tried the Events page, but could not find anything exactly relevant. Except for "After Record Added". Can this be used for Add Page Query?
I tried this:

____



*global $conn;

$strSQLInsert = "insert into course_category_table (--rbegin--Country-Category, Country-Category-College--rend--) values (CONCATENATE(Country,"-",Category), CONCATENATE(Country,"-",Category,"-",College))";

db_exec($strSQLInsert,$conn);*

_____________________________________________________________________________________________________


What bout Update? I tried "After Record Updated"? But how do i get the condition. I wrote the query as:

_____



*global $conn;

$strSQLInsert = "update course_category_table set 'Country-Category'=CONCATENATE(Country,"-",Category), 'Country-Category-College'=CONCATENATE(Country,"-",Category,"-",College) where ?????####";

db_exec($strSQLInsert,$conn);*

_____________________________________________________________________________________________________


Will this do what i want to happen? Can you help me out in this?
By the way, its an awesome s/w. Amazing functionalities you have put in this great package. Keep up the GR8 job Guys...

Sergey Kornilov admin 12/8/2010

Answered to your personal email.

P
pidejean 12/9/2010

Dear Admin,
I have tried every things but I did'nt succeed to Hide or Show a field according to the entry value off another field. I have used the US country/state video example and the example in this link:
http://www.asprunner.com/forums/topic/15378-how-to-hide-controls-on-addedit-pages/pagehlhidediv1fromsearch1
I have uploaded my example with Demo account
Please help me
Pierre

Sergey Kornilov admin 12/9/2010

Pierre,
you need to contact support team directly at http://support.xlinesoft.com sending your demo account URL.