By: webys
Date: 2005-12-01
Time: 14:00
|
TBS supports array form fields - for check/radio boxes ???
TBS supports array form fields - for check/radio boxes ???
E.g.: If I have html template form:
<form action="" method="get">
<input name="field_name[]" type="checkbox" value="[arr.id]">[arr.name]
<input name="field_name[]" type="checkbox" value="[arr.id]">[arr.name]
<input name="field_name[]" type="checkbox" value="[arr.id]">
[arr.name]
</form>
how can I make one or more checkboxes to be selected on value [arr.id] and generate sel_id automatically 1..n depends on [arr.id]?
[var.sel_id[arr.id];selected=field_name[]]
Thanks in advance. :)
|
By: Skrol29
Date: 2005-12-01
Time: 14:12
|
Re: TBS supports array form fields - for check/radio boxes ???
Hello,
I'm not sure to understal all well. Does [arr.id] have the same value for all <input> tags ?
And I don't understand what you mean by "generate sel_id automatically".
What I understand is that you'd like to pre-select several checkboxes which have the same Html name, and the same value. But the checking depends on its index and the variable $sel_id. Is that correct ?
|
By: webys
Date: 2005-12-05
Time: 07:51
|
Re: TBS supports array form fields - for check/radio boxes ???
Yes I wish to select one, or more of checkboxes wirh field name field_name[] (array checkboxe field). If array arr has 3 values 1,2,3 I wish that let's say where checkboxe field name field_name[] has value 1 and 3 to be selected aster parsing the template, final result.
If is other way that works this was an unworked ex ...[var.sel_id[arr.id];selected=field_name[]].
Thanks in advance.
|
By: webys
Date: 2005-12-09
Time: 07:39
|
Re: TBS supports array form fields - for check/radio boxes ???
Can TBS do that ?
|
By: Skrol29
Date: 2005-12-09
Time: 15:33
|
Re: TBS supports array form fields - for check/radio boxes ???
Hello,
Sorry to be long to reply. I'm still confused because I don't figure out how data comes from.
> If array arr has 3 values 1,2,3...
Do you mean you have variable $arr which contains 3 items?
Is that something like this:
$arr[] = array('id'=>1, 'name'=>'name1')
$arr[] = array('id'=>2, 'name'=>'name2')
$arr[] = array('id'=>3, 'name'=>'name2')
?
Or do you get this data by merging a block named 'arr' ?
If we note that the TBS way of selecting checkboxes is not able to do what you need, you can try it differently. For exemple:
<input name="field_name[]"
type="checkbox"
value="[arr.id]"
[arr.id;noerr;if [val]=1;then 'checked="checked"';else '']
>
|
|
By: webys
Date: 2006-02-20
Time: 15:27
|
Re: TBS supports array form fields - for check/radio boxes ???
data comes from database ...
<input name="field_name[]" type="checkbox" value="1">
<input name="field_name[]" type="checkbox" value="3">
<input name="field_name[]" type="checkbox" value="3">
with :
<input name="field_name[]"
type="checkbox"
value="[arr.id]"
[arr.id;noerr;if [val]=1;then 'checked="checked"';else '']
>
I can check just if value of arr is 1 I wish to show the checkboxes checked programatically something like
if if [val] in arr2 check the checkbox
arr2 is an array with checked checkboxes ex if user click submit on a form I wish to show him/her what he checked. I have te arr2 in a php session.
If in my session I have arr2=array(1,2); I need the checked bokes with id 1, 2 to be checked and checkboxe with id 3 uncheck .
Can I do that ?
Tx.
|
By: Skrol29
Date: 2006-02-20
Time: 17:08
|
Re: TBS supports array form fields - for check/radio boxes ???
Yes and it is simple :
HTML :
<form>
<input name="field_name[]" type="checkbox" value="1">
<input name="field_name[]" type="checkbox" value="3">
<input name="field_name[]" type="checkbox" value="3">
[var.arr2;selected='field_name[]']
</form>
|
PHP :
|
By: webys
Date: 2006-02-21
Time: 16:24
|
Re: TBS supports array form fields - for check/radio boxes ???
It worked with:
[var.arr2;selected='field_name[]']
Tx Skrol29.
|
|
Posting in progress.
Please wait...
|