Name

checked — indicate checked status of checkboxes

ATTRIBUTES

Attribute Pos. Req. Default Description
name Yes variable name
value Yes on
cgi Whether to use CGI namespace instead of Value namespace.
default None
case No Preserve case for field names and values?
multiple
delimiter \0 This option implies multiple=1.
interpolate     0 interpolate output?
hide     0 Hide the tag return value?

DESCRIPTION

The tag provides "memory" for HTML checkboxes and radio buttons.

BEHAVIOR

This tag does not appear to be affected by, or affect, the rest of Interchange.

EXAMPLES

Example: "Memory" for checkboxes

<pre>

<form action="[process href="@@MV_PAGE@@"]" method="post">
  [form-session-id]
  <input type=hidden name=mv_todo value=refresh>
  
  <input type=checkbox name=checkbox1 [checked name=checkbox1 cgi=1]> Option1
  <input type=checkbox name=checkbox2 [checked name=checkbox2 cgi=1]> Option2
  <input type=checkbox name=checkbox3 [checked name=checkbox3 cgi=1]> Option3
  <input type=checkbox name=checkbox4 [checked name=checkbox4 cgi=1]> Option4
  <input type=checkbox name=checkbox5 [checked name=checkbox5 cgi=1]> Option5
  
  <input type=submit>
</form>

</pre>

Example: Radio Button

Displays a radio button and selects the second choice by default:

<input type="radio" name="factory_sealed" value="1"[checked factory_sealed 1]>&nbsp;[L]Yes[/L]<br>
<input type="radio" name="factory_sealed" value="0"[checked factory_sealed value=0 default=1]>&nbsp;[L]No[/L]

NOTES

AVAILABILITY

checked is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/SystemTag/checked.coretag
Lines: 57


# Copyright 2002-2007 Interchange Development Group and others
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: checked.coretag,v 1.9 2007-03-30 23:40:49 pajamian Exp $

UserTag checked             Order        name value
UserTag checked             addAttr
UserTag checked             Implicit     multiple multiple
UserTag checked             Implicit     default default
UserTag checked             PosNumber    2
UserTag checked             Version      $Revision: 1.9 $
UserTag checked             Routine      <<EOR
sub {
my ($field,$value,$opt) = @_;

$value = 'on' unless defined $value;

my $ref = $opt->{cgi} ? $CGI::values{$field} : $::Values->{$field};
return ' checked="checked"' if ! length($ref) and $opt->{default};

if(! $opt->{case}) {
  $ref = lc($ref);
  $value = lc($value);
}

return ' checked="checked"' if $ref eq $value;

if ($opt->{delimiter}) {
  $opt->{multiple} = 1;
}

if ($opt->{multiple}) {
    
    my $be;
    my $ee;
    $opt->{delimiter} = "\0" unless defined $opt->{delimiter};

    if (length $opt->{delimiter}) {
  my $del = Vend::Interpolate::get_joiner($opt->{delimiter}, "\0");
  $be = '(?:^|' . $del . ')'; ;
  $ee = '(?:$|' . $del . ')'; ;
    }
    else {
  $be = '';
  $ee = '';
    }

    my $regex = qr/$be\Q$value\E$ee/;
    return ' checked="checked"' if $ref =~ $regex;
}
return '';
}
EOR

AUTHORS

Interchange Development Group

SEE ALSO

selected(7ic)

DocBook! Interchange!