Buy Now
Sign in

Need The First Option in a Radio Group to be Selected

cre8tivemedia , September 05 at 18:29
Answered
C
cre8tivemedia
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
healyhatman
{var:data source.0}
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman
C
cre8tivemedia
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)
54 Downloads/Views
healyhatman
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
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman
C
cre8tivemedia
debugger.png
Attachments
debugger.png
debugger.png
(28.95 KiB)
43 Downloads/Views
healyhatman
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
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman
C
cre8tivemedia
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)
45 Downloads/Views
php.png
php.png
(16.52 KiB)
41 Downloads/Views
selected-value.png
selected-value.png
(43.88 KiB)
39 Downloads/Views
radio.png
radio.png
(34.82 KiB)
43 Downloads/Views
result.png
result.png
(39.43 KiB)
42 Downloads/Views
healyhatman
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
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman
C
cre8tivemedia
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));
healyhatman
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
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman
C
cre8tivemedia
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.