Forums

Need The First Option in a Radio Group to be Selected

cre8tivemedia 05 Sep, 2018
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 06 Sep, 2018
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
healyhatman 06 Sep, 2018
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}
cre8tivemedia 06 Sep, 2018
If I leave the selected value field blank then nothing is selected



I tried adding a php action after the read data like this -



and changed the selected value -



this is the result -

healyhatman 06 Sep, 2018
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
cre8tivemedia 06 Sep, 2018
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 07 Sep, 2018
Answer
1 Likes
return max(array_keys($this->get("read_data#", "")));

Don't copy paste, you need to type it manually. The forums adds in invisible characters.
cre8tivemedia 07 Sep, 2018
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.
This topic is locked and no more replies can be posted.