Hello. I created the form "name selection". In the form there are 3 drop-down list: 1) "select gender", 2) "male names", 3) "female names".
Also I have added in the database table with the fields: "id", "gender" and "name". This table stores all the names in the form of 1 Andrew male; 2 Jane female; and so on...
[IMG]http://s8.postimg.org/67d75xr9x/image.jpg[/IMG]
A list of 2 and 3 are hidden and appear when you select values in list 1.
The idea is that when the selection in the first list of values "Male names list "2" should appear only male names. When selecting "Female names" - only female. But actually in the list 2 and 3 are loaded all the names from a database table.
How to make a list of the names are loaded only male or female names? Please explain step by step.
Also I have added in the database table with the fields: "id", "gender" and "name". This table stores all the names in the form of 1 Andrew male; 2 Jane female; and so on...
[IMG]http://s8.postimg.org/67d75xr9x/image.jpg[/IMG]
A list of 2 and 3 are hidden and appear when you select values in list 1.
The idea is that when the selection in the first list of values "Male names list "2" should appear only male names. When selecting "Female names" - only female. But actually in the list 2 and 3 are loaded all the names from a database table.

How to make a list of the names are loaded only male or female names? Please explain step by step.
I would put two extra DBReads on the Setup.
In the first:
Model id = male
Conditions:
in the second:
Model id = female
Conditions:
And use these for the dropdowns.
Rob
In the first:
Model id = male
Conditions:
<?php
return array ("select_gender = "male");
?>
in the second:
Model id = female
Conditions:
<?php
return array ("select_gender = "female");
?>
And use these for the dropdowns.
Rob
Hello, RobP!
Thanks for the help. All of you are well explained, only in the code You have there is an error and it doesn't work.
I replaced Your code:
<?php return array ("select_gender = "female"); ?>
this:
<?php return array ('select_gender' => 'female'); ?>
and everything worked perfectly. Thanks again for the help!
Thanks for the help. All of you are well explained, only in the code You have there is an error and it doesn't work.
I replaced Your code:
<?php return array ("select_gender = "female"); ?>
this:
<?php return array ('select_gender' => 'female'); ?>
and everything worked perfectly. Thanks again for the help!
I missed a quote.
It should have be:
<?php return array ("select_gender = 'female' "); ?>
You give the SQL a command to return the records where select_gender = "female'
With
<?php return array ('select_gender' => 'female'); ?>
you probably do a compare and select on the loaded array values.
For small tables it won't make much difference, but I prefer to let the MySql server handle the selects.
Rob
It should have be:
<?php return array ("select_gender = 'female' "); ?>
You give the SQL a command to return the records where select_gender = "female'
With
<?php return array ('select_gender' => 'female'); ?>
you probably do a compare and select on the loaded array values.
For small tables it won't make much difference, but I prefer to let the MySql server handle the selects.
Rob
I understood.
Apparently I have something does not work correctly, because if I use this code:
<?php return array ("select_gender = 'female' "); ?>
I get just a blank page and this:
Fatal error: Call to undefined method RuntimeException::get() in Z:\home\mysite.ru\www\libraries\legacy\error\error.php on line 533
Apparently I have something does not work correctly, because if I use this code:
<?php return array ("select_gender = 'female' "); ?>
I get just a blank page and this:
Fatal error: Call to undefined method RuntimeException::get() in Z:\home\mysite.ru\www\libraries\legacy\error\error.php on line 533
I checked the debug info, both:
<?php return array ("select_gender = 'female' "); ?>
<?php return array ('select_gender' => 'female'); ?>
result in the same query.
Rob
<?php return array ("select_gender = 'female' "); ?>
<?php return array ('select_gender' => 'female'); ?>
result in the same query.
Rob
Hi vladimirvnr,
The error message you are seeing is a Joomla! Error, not directly from ChronoForms. Not something that I've seen before.
Bob
The error message you are seeing is a Joomla! Error, not directly from ChronoForms. Not something that I've seen before.
Bob
Hello. I have a new problem: how do I add additional value from another column in the database table?
For example, now I have a list of company employees working on separate floors of the building. In the database table added new columns: "Floor", "office Number" and "Profession".
In the first list, the user selects the number of the floor. And in the second list displays the employees working on the selected floor.
How do I make the second drop-down list items were: "Name" + "Profession" + "office Number"?
For example: Max (director) No. 5; Ben (manager) No. 8; etc.
For example, now I have a list of company employees working on separate floors of the building. In the database table added new columns: "Floor", "office Number" and "Profession".
In the first list, the user selects the number of the floor. And in the second list displays the employees working on the selected floor.
How do I make the second drop-down list items were: "Name" + "Profession" + "office Number"?
For example: Max (director) No. 5; Ben (manager) No. 8; etc.
This topic is locked and no more replies can be posted.