Buy Now
Sign in

Need The First Option in a Radio Group to be Selected

cre8tivemedia , September 05 2018, 18:29
C
cre8tivemedia 92
September 05 2018, 18:29 #380023
I've set a radio group array to arrange the values in descending order. I would like to have the first value (the largest number) to be pre-selected. I've tried a number of things in the "selected value" field but can't figure out the proper syntax. I can get it to work if I know ahead of time what the largest number will be... unfortunately, with the array this number changes constantly.
Any thoughts?
Thanks,
Matt
DealGetR.com
healyhatman 6
September 05 2018, 21:40 #380025
{var:data source.0}
Web developer at SkySpider.com.au
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
C
cre8tivemedia 92
September 06 2018, 14:41 #380041
Still can't get it to work, not sure where I'm going wrong but I tried these as well
{var:radio123.0}
{var:radio1230.0}
{var:read_data10.0}
and a couple others...
This is what I have right now -
radio.png
and the front end link -
thanks,
Matt
CFV6
Joomla 3.8.12
Attachments
radio.png
radio.png
(24.74 KiB)
121 Downloads/Views
DealGetR.com
healyhatman 6
September 06 2018, 21:45 #380049
Well it should be var read data, definitely not var radio.
Put a debug in as the last action on page load and post it
Web developer at SkySpider.com.au
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
C
cre8tivemedia 92
September 06 2018, 22:02 #380050
debugger.png
Attachments
debugger.png
debugger.png
(28.95 KiB)
111 Downloads/Views
DealGetR.com
healyhatman 6
September 06 2018, 22:23 #380051
So if you don't put anything in selected value and you don't put an empty option at the top it should ALREADY be selected. So if you don't put anything in the selected value box, what happens for you?
Either that OR put a PHP action after your read data, loop through ($this->get("read_data10", "deault")), return the largest number, and then in Selected Value put {var:phpaction}
Web developer at SkySpider.com.au
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
C
cre8tivemedia 92
September 06 2018, 22:54 #380052
If I leave the selected value field blank then nothing is selected
selected-value.png
I tried adding a php action after the read data like this -
php.png
and changed the selected value -
radio.png
this is the result -
result.png
Attachments
selected-value.png
selected-value.png
(43.88 KiB)
112 Downloads/Views
php.png
php.png
(16.52 KiB)
104 Downloads/Views
selected-value.png
selected-value.png
(43.88 KiB)
93 Downloads/Views
radio.png
radio.png
(34.82 KiB)
110 Downloads/Views
result.png
result.png
(39.43 KiB)
108 Downloads/Views
DealGetR.com
healyhatman 6
September 06 2018, 22:56 #380053
You can't just put that in the PHP action you have to actually put code in there. That code I gave you was how to get the array you were after, now you need to search through it
Web developer at SkySpider.com.au
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
C
cre8tivemedia 92
September 06 2018, 23:58 #380054
Sorry, wish I understood a little better but not as versed as I'd like to be. I need to add additional code to the PHP action or do I add it in javascript?
something like this in PHP?
echo(max(array(var:read_data10));
DealGetR.com
healyhatman 6
September 07 2018, 00:24 #380055
 1
 Answer
return max(array_keys($this->get("read_data#", "")));
Don't copy paste, you need to type it manually. The forums adds in invisible characters.
Web developer at SkySpider.com.au
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
C
cre8tivemedia 92
September 07 2018, 12:15 #380062
Thanks again healyhatman, took me a little bit but I finally got it to work.
Still not that used to dealing with PHP but I'm learning.
DealGetR.com