Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Help using RADIO buttons ?.

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
gordonisnz
Smarty Regular


Joined: 05 Sep 2009
Posts: 70

PostPosted: Sun Aug 23, 2020 9:52 am    Post subject: Help using RADIO buttons ?. Reply with quote

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
View user's profile Send private message
gordonisnz
Smarty Regular


Joined: 05 Sep 2009
Posts: 70

PostPosted: Sun Aug 23, 2020 10:29 am    Post subject: Reply with quote

Radio buttons cant do multiples. Looking for CHECKBOXES but its not a 'standard' function. Doing my own
Back to top
View user's profile Send private message
gordonisnz
Smarty Regular


Joined: 05 Sep 2009
Posts: 70

PostPosted: Sun Aug 23, 2020 11:31 am    Post subject: Reply with quote

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
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Wed Aug 26, 2020 2:21 pm    Post subject: Reply with quote

https://www.smarty.net/docs/en/language.function.html.checkboxes.tpl
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP