Forums

fill dropdown with record of table.

salvok5 08 Feb, 2017
hi Max.

Now let me explain better.
Then these settings:

Events->index->content
{fn:richiama_valori_tipo}
{view:Campi-ricerca}
{debug:}

Functions->richiama_valori_tipo
Select type -> set to key/value pairs, and pagination disabled
Fields to retrieve->GRUPPO:GRUPPO
"this is an extra fields list" disabled.
Group fields ->GRUPPO

Views->Campi-ricerca->Dropdown
Options ->{var:richiama_valori_tipo}

From these records
TITOLO_SECT | GRUPPO
Avvisi sindacali | 1
Avvisi momentanei | 1
Delibere momentanei | 2
Delibere Tipo | 2
Delibere Vari | 2
Determine | 3
Determine varie | 3
Determine tipo | 3

I get:
So I get on-screen display of the dropdown list:
1
2
3

Instead I want to show this from field TITOLO_SECT:
Avvisi
Delibere
Determine



As you suggested it will not work.
Max_admin 09 Feb, 2017
Hi Salvo,

This is because you have only the gruppo field in the fields to retrieve list, The Fields to retrieve should include 2 fields:

GRUPPO:GRUPPO
tittolo:tittolo

this way the gruppo field is used as the options values, and titolo as text

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
salvok5 09 Feb, 2017
Ok, now it works, but do not see only the first word of the title, but you see the entire title.
I see this:
Avvisi sindacali
Delibere momentanei
Determine

it should be this:
Avvisi
Delibere
Determine

Now how do I call a function that returns only the first word?
If I insert that does not work:

Fields to retrieve->
GRUPPO:GRUPPO
TITOLO_SECT:{fn:solo_titolo}

Functions->solo_titolo
code : echo explode(" ",$this->get("richiama_valori_tipo.row.docu.TITOLO_SECT"))[0];
Max_admin 10 Feb, 2017
Hi Salvo,

First, try this code in the fields to retrieve:
titolo:substring_index(Model.titolo, " ", 1)

if it works then good, if not then you need a php function run after the "read data" function:

$options = $this->get("read_data_fn");
foreach($options as $key => $value){
$options[$key] = explode(" ", $value)[0];
}
return $options;


now use this in the options box:
{fn:read_data_name}{fn:php_fn_name}{var:php_fn_name}


Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
salvok5 10 Feb, 2017

Hi Salvo,

First, try this code in the fields to retrieve:
titolo:substring_index(Model.titolo, " ", 1)

if it works then good, .....:



it's not work
Parse error: syntax error, unexpected '",1)"' (T_CONSTANT_ENCAPSED_STRING), expecting ']' in /web/htdocs/www.clubk5.org/home/libraries/cegcore2/libs/arr.php(71) : eval()'d code on line 1
salvok5 10 Feb, 2017
1 Likes

Hi Salvo,

...if not then you need a php function run after the "read data" function:


it's not work.
there was an error in fact taking away from options box: {fn:read_data_name}

and entering only this
{fn:php_fn_name}{var:php_fn_name}
it's WORK !!!
Thank
webcrea 20 Apr, 2017
for me, 15 lines in the table and

is the result only one option which contains

[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null]


before in Event/view/content : {fn:php-versions-options} with the Max script just after the {fn:read-versions}

in options of the field : {fn:php-versions-options}{var:php-versions-options}

in debug the query is ok

it seams i'm close to solve it but i can't...
an idea?
thanks
Max_admin 21 Apr, 2017
Hi Chris,

You need to list the data into the table or load a dropdown with options ?

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
webcrea 21 Apr, 2017
Hello Max,

A simple dropdown fuelled by id(value) and alias(label) from a table.

thanks
Max_admin 22 Apr, 2017
1 Likes
Hi Chris,

You need a "Read data" function to run before the fields view is called, in the function set the "Select type" to "Key/value pairs" and the fields list to:

Model_Name.key
Model_Name.value

where key and value are 2 fields in your table.

In the dropdown options field, write down: {var:read_data_fn_name}

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
webcrea 22 Apr, 2017
Nice
Thanks Max
webcrea 24 Apr, 2017
Hi Max,

The dropdown'id is versions_list and i try to get his value in js with :

var id_versions = jQuery("#versions_list option:selected").val();

but undefined value is retrun, could you tell me how to do, please ?

Regards
Max_admin 24 Apr, 2017
Hi Chris,

I think that jQuery("#versions_list").val() is right way to get the dropdown value.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
webcrea 24 Apr, 2017
hi,

No always the same undefined and in the inspector i see

<div class="ui dropdown selection" tabindex="0"><select data-events="[]" name="versions-list[]" id="versions-list" data-mincharacters="0" type="select"><option value="26">ALSACE-ML-ENGLISH-3</option>
<option value="14">BORDEAUX-ML-ENGLISH-2</option>
<option value="22">BORDEAUX-ML-ENGLISH-3-1</option>
<option value="19">BORDEAUX-ML-ENGLISH-45</option>
<option value="25">BOURGOGNE-ML-ENGLISH-13TH-EDITION</option>
<option value="27">CHAMPAGNE-ML-ENGLISH-2-1</option>
<option value="13">FWS-ENGLISH-4-AND-OLDER</option>
<option value="11">FWS-ENGLISH-5-2</option>
<option value="20">FWS-ENGLISH-6-1</option>
<option value="12">FWS-SPANISH-5-2</option>
<option value="15">IWS-UNIT1-ENGLISH-1</option>
<option value="28">IWS-UNIT2-ENGLISH-1</option>
<option value="23">PROVENCE-ML-ENGLISH-4-0</option>
<option value="21">RHONE-ML-ENGLISH-4-2</option>
<option value="24">SUD-DE-FRANCE-ML-ENGLISH-APRIL-2016</option></select>

<i class="dropdown icon"></i><div class="text">PROVENCE-ML-ENGLISH-4-0</div><div class="menu transition hidden" tabindex="-1"><div class="item" data-value="26" style="">ALSACE-ML-ENGLISH-3</div><div class="item" data-value="14">BORDEAUX-ML-ENGLISH-2</div><div class="item" data-value="22">BORDEAUX-ML-ENGLISH-3-1</div><div class="item" data-value="19">BORDEAUX-ML-ENGLISH-45</div><div class="item" data-value="25">BOURGOGNE-ML-ENGLISH-13TH-EDITION</div><div class="item" data-value="27" style="">CHAMPAGNE-ML-ENGLISH-2-1</div><div class="item" data-value="13">FWS-ENGLISH-4-AND-OLDER</div><div class="item" data-value="11">FWS-ENGLISH-5-2</div><div class="item" data-value="20">FWS-ENGLISH-6-1</div><div class="item" data-value="12">FWS-SPANISH-5-2</div><div class="item" data-value="15">IWS-UNIT1-ENGLISH-1</div><div class="item" data-value="28">IWS-UNIT2-ENGLISH-1</div><div class="item active selected" data-value="23">PROVENCE-ML-ENGLISH-4-0</div><div class="item" data-value="21">RHONE-ML-ENGLISH-4-2</div><div class="item" data-value="24">SUD-DE-FRANCE-ML-ENGLISH-APRIL-2016</div></div></div>
Max_admin 24 Apr, 2017
Hi Chris,

This is a multi value select, maybe the code below can work for you:

var inp = "#versions-list";
var value = jQuery(inp).find(':selected').data('value') ? jQuery(inp).find(':selected').data('value') : jQuery(inp).val(); 


Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
webcrea 24 Apr, 2017
1 Likes
Fine I understand my error I tried to get value of versions_list unstead versions-list...

Thanks a lot
This topic is locked and no more replies can be posted.