Buy Now
Sign in

DROPDOWN dynamically feed

extrom , June 28 at 15:24
E
extrom
I am using chronoforms v6 and noticed that in many cases there is no need to create extra code for some functions.​
​I am counting the number of records in a database and hovering LOOP to generate a list for a DROPDOWN ...​
​Example: I find that I have 4 records in a database, how to dynamically feed a DROPDOWN with the "1,2,3,4" choice options?​
​Is there a way to implement without generating extra code?
healyhatman
There's a dynamic dropdown example in the demo forms.
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman
E
extrom
I am using a PHP to populate the dropdown with a count of database records, one same works well plus I have to get the maximum value of records that comes from the amount of records in the database. The value is in read_data15 it indicates that it is number 3, however when using in "for" this value is ZERO ...
//return array("Ponto 1","Ponto 2","Ponto 3","Ponto 4",); ​
​$results = array();​
​$quant = '{var:read_data15}';​
​$results
  • = 'Selecione o ponto desejado';​
    ​for ($i = 1; $i <= $quant; $i++) {​
    ​ $results
  • = 'Ponto '.$i;​
    ​}​
    ​return $results;
    how can I get around this problem?
    E
    extrom
    //return array("Ponto 1","Ponto 2","Ponto 3","Ponto 4",); ​
    ​$results = array();​
    ​$quant = '{var:read_data15}';​
    ​$results
  • = 'Selecione o ponto desejado';​
    ​for ($i = 1; $i <= $quant; $i++) {​
    ​ $results
  • = 'Ponto '.$i;​
    ​}​
    ​return $results;
    healyhatman
    var:read_data.model
    Web developer at SkySpider.com.au
    I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman
    E
    extrom
    return '{var:read_data15}';
    by simply testing with this I get the value 3 ...
    E
    extrom
    Healyhatman...
    thus ?
    $results = array();​
    ​$quant = '{var:read_data15.model}';​
    ​$results[ ] = 'Selecione o ponto desejado';​
    ​for ($i = 1; $i <= $quant; $i++) {​
    ​ $results[ ] = 'Ponto '.$i;​
    ​}​
    ​return $results;
    healyhatman
    m are you sure it's 3, or is it an array containing the number 3
    Web developer at SkySpider.com.au
    I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman
    E
    extrom
    I am counting records through the option below in read_data15 and currently have 3 records ... I need this value inside the "for" to be able to create 3 elements in the array that goes to the dropdown when returning from PHP
    the read_data15...
    Select type = Return the count of records matching the filtering conditions.
    healyhatman
    Oh sorry I see the problem. You can't use shortcode a in PHP.
    {var:} should be $this->get("variable name", "default if not found");
    Web developer at SkySpider.com.au
    I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman
    E
    extrom
    any problem to overcome the problem?
    healyhatman
    I just told you? What is it you're asking?
    Web developer at SkySpider.com.au
    I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman
    E
    extrom
    Thanks, follow a link to video with the implementation.
    https://youtu.be/mkr_460kmuM
    healyhatman
    $quant = $this->get("read_data15", 0);
    You didn't read what I wrote properly, $this->get takes two parameters - the name of the variable you want to retrieve, and a default value if the variable is not found.
    Web developer at SkySpider.com.au
    I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman
    healyhatman
    Also try doing
    return json_encode($results);
    and in the dropdown value put
    {var/jsonde:php17}
    Web developer at SkySpider.com.au
    I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman
    E
    extrom
    Thanks a lot for the guidance, you are correct ... however the implementation described in the video is working correctly ... at the time I noticed that $ this in the chronoforms is an access to the entire structure of the project simply by knowing how to access the desired variables, thank you...​
    ​​
    ​Throughout my code I will certainly have other doubts, thank you very much.