RE: Checking a checkbox using the value
"Peter Marklund" <[email protected]> Wed, 28 Jan 2004 15:55:49 +0100
| Newsgroups | gmane.comp.web.tclwebtest |
|---|---|
| Message-ID | <[email protected]> |
Hey Michael!
I happened to come across the need to check some checkboxes myself. It's
odd, I always assumed you could use field select for them but it seems
you can't. However, I drafted a new proc that you can get if you cvs
update / checkout tclwebtest. Here is the proc:
ad_proc -private field_check_multiple {
checkbox_name
checkbox_values
} {
Loop over a group of checkboxes with a given name and select
those with a value matching a list of values.
@checkbox_name The name of the checkboxes to check
@checkbox_values A list of values that indicate which checkboxes to
check
@autor Peter Marklund
} {
while { 1 } {
if { [catch {field find -next ~n $checkbox_name ~t checkbox}] } {
# No more checkboxes
break
}
=20=20=20=20=20=20=20=20
array set current_field [::tclwebtest::field_current]
set checkbox_value [lindex $current_field(choices) 1]
if { [lsearch -exact $checkbox_values $checkbox_value] !=3D -1 } {
field check
} else {
# field_find -next will give us the current field eternally
as
# long as it hasn't been modified so increment current field
manually
incr ::tclwebtest::current_field
}
}
}
Use it like this:
field check_multiple my_checkbox_name [list value1 value2 value3]
Peter
=20
----------------------------
Peter Marklund
C/O Thomas Sch=F6nbeck
Oster Farimagsgade 77
2100 Copenhagen
Denmark
Work Phone: +45-33436380
Mobile phone: +45-20820101
Home phone: +45-35559440
http://collaboraid.biz
http://petermarklund.com
----------------------------
http://fastmail.fm - the way e-mail *should* be
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn