Buy Now
Sign in

DROPDOWN dynamically feed

extrom , June 28 2018, 15:24
E
extrom 29
June 28 2018, 15:24 #378652
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 8
June 28 2018, 22:19 #378654
There's a dynamic dropdown example in the demo forms.
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
E
extrom 29
June 28 2018, 22:58 #378656
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 29
    June 28 2018, 22:59 #378657
    //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 8
    June 28 2018, 23:01 #378658
    var:read_data.model
    Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
    Donations: paypal.me/healyhatman
    Professional Work: kamron@skyspider.com.au
    Custom CF / CC Plugins and Extensions: skyspider.com.au/store
    E
    extrom 29
    June 28 2018, 23:01 #378659
    return '{var:read_data15}';
    by simply testing with this I get the value 3 ...
    E
    extrom 29
    June 28 2018, 23:06 #378660
    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 8
    June 28 2018, 23:12 #378661
    m are you sure it's 3, or is it an array containing the number 3
    Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
    Donations: paypal.me/healyhatman
    Professional Work: kamron@skyspider.com.au
    Custom CF / CC Plugins and Extensions: skyspider.com.au/store
    E
    extrom 29
    June 28 2018, 23:16 #378662
    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 8
    June 28 2018, 23:17 #378663
    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 DO NOT work for ChronoEngine!
    Donations: paypal.me/healyhatman
    Professional Work: kamron@skyspider.com.au
    Custom CF / CC Plugins and Extensions: skyspider.com.au/store
    E
    extrom 29
    June 28 2018, 23:19 #378664
    any problem to overcome the problem?
    healyhatman 8
    June 29 2018, 02:04 #378665
    I just told you? What is it you're asking?
    Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
    Donations: paypal.me/healyhatman
    Professional Work: kamron@skyspider.com.au
    Custom CF / CC Plugins and Extensions: skyspider.com.au/store
    E
    extrom 29
    June 29 2018, 02:10 #378666
    Thanks, follow a link to video with the implementation.
    https://youtu.be/mkr_460kmuM
    healyhatman 8
    June 29 2018, 02:13 #378667
    $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 DO NOT work for ChronoEngine!
    Donations: paypal.me/healyhatman
    Professional Work: kamron@skyspider.com.au
    Custom CF / CC Plugins and Extensions: skyspider.com.au/store
    healyhatman 8
    June 29 2018, 02:17 #378668
    Also try doing
    return json_encode($results);
    and in the dropdown value put
    {var/jsonde:php17}
    Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
    Donations: paypal.me/healyhatman
    Professional Work: kamron@skyspider.com.au
    Custom CF / CC Plugins and Extensions: skyspider.com.au/store
    E
    extrom 29
    June 29 2018, 11:39 #378680
    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.