|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
gordonisnz Smarty Regular
Joined: 05 Sep 2009 Posts: 70
|
Posted: Sun Aug 23, 2020 9:52 am Post subject: Help using RADIO buttons ?. |
|
|
https://www.smarty.net/docsv2/en/language.function.html.radios.tpl
Hello. Ive found the above, but its not doing what i want.
Has anyone got a working example of a script ? Im trying to follow the abovem but getting lost.
Code: | html_radios: the "selected" attribute cannot be an array in .... |
my code :-
Code: |
{$tmp = ksort($formservices)}
{html_radios name='formservices' options=$formservices
selected=$formservices separator='<br />'}
|
$formservices is the array of the values i have (things i can select)
I start off with 10+ items *ALL* not-selected (no pre-selected items..) - so what do i put here ? :- selected=$formservices
Also, the way ive got it now, i can only select one at a time (all hasve the same NAME.
Code: | input type="radio" name="formservices" |
What i want :-
a) start off with a list of 10+ items in my array..
b) NONE of them pre-selected
c) the ability for a user to select one OR MORE entries
I'll also have a TEXT field - so that a person can add another option - I'll refresh the form & re-display the new radio buttons, including the new entry.
has anyone got an example like this ?
EDIT:-
How do i control
a) the list of all possible results (selected & non selected)
b) which ones the user has selected ? |
|
Back to top |
|
gordonisnz Smarty Regular
Joined: 05 Sep 2009 Posts: 70
|
Posted: Sun Aug 23, 2020 10:29 am Post subject: |
|
|
Radio buttons cant do multiples. Looking for CHECKBOXES but its not a 'standard' function. Doing my own |
|
Back to top |
|
gordonisnz Smarty Regular
Joined: 05 Sep 2009 Posts: 70
|
Posted: Sun Aug 23, 2020 11:31 am Post subject: |
|
|
Ive got this code..
Code: |
{$tmp = ksort($formservices)}
{foreach from=$formservices key=k item=v}
<input type="checkbox" name="SERVICETICK[]" value="{$k}" {if in_array($k,$SERVICETICK)}checked{/if}><label for="SERVICETICK{$k}">{$k}</label><br>
{/foreach}
|
$formservices - array of all services available
$SERVICETICK - an array of those services a person has ticked. |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|